1 Introduction

Economic Latin-American time series variables can be complex with high frequency data. From a frequentist perspective, techniques for fitting time series models use a preliminary data-set transformation in order to get stationarity and therefore important information about the dynamic system can be lost. On the other hand, from a Bayesian perspective the use of RBDMs with weakly-robust priors for the observation and state variances has been revolutionary in recent years due to flexibility for detecting outliers and structural breaks, the straightforward computational techniques based in Markov Chain Monte Carlo (MCMC) and the natural update from Bayes theorem without a preliminary data-set transformation.

From a frequentist perspective the study of time series with structural changes has been of far reaching in econometric theory for univariate time series, frequentist dynamic models, volatility and even financial return models. The seminal paper of Tsay (1988) considers least square techniques and residual variance ratios for detecting outliers, level shifts and variance changes in univariate time series. Hansen (2000) introduces a bootstrap method for detecting structural changes in regressors including structural shifts, polynomial trends and exogenous stochastic trends for frequentist dynamic econometric models. For volatility models, Vladimir (2009) uses local chance point analysis to intervals of homogeneity in order to account possible structural breaks. Fryzlewicz and Rao (2013) propose a method based in process transformation and binary segmentation for detecting multiple change points in auto-regressive conditional heteroscedastic models for financial returns.

From a Bayesian perspective in recent years RBDMs for detecting structural breaks have been proposed as an alternative to the usual Bayesian dynamic models. Ardia and Hoogerheide (2010) propose a Bayesian generalized autoregressive conditional heteroscedasticity dynamic model with Student-t innovations with applications to the R program (R Development Core Team 2015). Polson and Scott (2011) apply heavy-tailed priors in order to examine historical patterns of return on assets to financial time series. Fúquene et al. (2014) propose a new flexible class of heavy-tailed priors for detecting outliers and structural breaks in Bayesian dynamic linear models.

However, even though the qualities of RBDMs in the best of our knowledge there are no application of RBDMs to economic Latin-American variables for detecting their historic outliers and structural breaks. Therefore, in this work we use the RBDMs proposed by Fúquene et al. (2014) to modelling the historic change points in Latin-American economic variables from Mexico and Puerto Rico. We use this methodology because: (1) we can model a considerable variety of dynamic models: random walk, local linear trend and seasonal or a combination of those models with weakly-robust priors for the observation and state variances, (2) the computational schemes can be applied easily for practitioners and (3) using RBDMs allows us to have posterior inference for the parameters from a Bayesian perspective.

The paper is organized as follows: Section 2 shows the prior variances specification for the RBDM. In Sect. 3, we apply a random walk RBDM to an economic time series of Mexico for detecting the historic outliers and level changes in the inflation of this country. Section 4 shows local trend and stationary RBDMs for accounting the abrupt changes in the economic recession periods in Puerto Rico. Finally we have the conclusions in Sect. 5.

2 Model specification

The dynamic linear model (DLM) is specified (see West and Harrison 1997) by a Normal prior distribution for the p-dimensional state vector at \(t=0\) as follows:

$$\begin{aligned} \varvec{\theta }_{0}\sim N_{p}(m_{0},C_{0}), \end{aligned}$$

with the set of equations:

$$\begin{aligned} y_{t}&=F_{t}\varvec{\theta }_{t}+\nu _{t}\quad \nu _{t}\sim N_{m}(0,V_{t}),\end{aligned}$$
$$\begin{aligned} \varvec{\theta }_{t}&=G_{t}\varvec{\theta }_{t-1}+\omega _{t}\quad \omega _{t}\sim N_{p}(0,W_{t}), \end{aligned}$$

with \(t=1:T\) and where \(F_{t}\) and \(G_{t}\) are known matrices of order \(p \times p\) and \(m \times p\) respectively. With \(\nu _{t}\) and \(\omega _{t}\) two independent Gaussian random vectors with mean zero and known variance \(V_{t}\) and \(W_{t}\) respectively. The observation equation and state equation are (2) and (3), respectively. A set of prior distributions for the observation and state variances may be considered in practice. For example in order to have closed form full conditionals we could use gamma prior densities. However, in the presence of highly frequency data heavy-tailed priors are the best alternative. The scaled Beta2 prior for the precision \(\lambda =1/\tau ^{2}\) is proposed in Fúquene et al. (2014) for modelling the variances (and precisions) in DLMs and defined as follows:

$$\begin{aligned} \pi (\lambda )=\frac{\Gamma (q+p)}{\Gamma (q)\Gamma (p)}\beta \frac{(\beta \lambda )^{q-1}}{\left( 1+\beta \lambda \right) ^{p+q}};\quad \lambda >0 \end{aligned}$$

where \(\beta\) is the scale parameter. This paper considers the Student-t density coupled with a scaled Beta2 for modelling the observation and state errors (as in Fúquene et al. 2014) in Latin-American economic time series from Mexico and Puerto Rico. So, let \(\theta \sim\) be a Student-t \((\mu ,\tau ,\upsilon )\) where \(\upsilon\) are the degrees of freedom, \(\mu\) the location and \(\tau\) the scale of the Student-t density:

$$\begin{aligned} \pi (\theta |\tau ^{2})=\frac{k_{1}}{\tau }\left( 1+\frac{1}{\upsilon } \left( \frac{\theta -\mu }{\tau }\right) ^{2}\right) ^{-(\upsilon +1)/2}, \quad \upsilon >0, -\infty <\mu <\infty , -\infty <\theta <\infty , \end{aligned}$$

where \(k_{1}=\dfrac{\Gamma ((\upsilon +1)/2)}{\Gamma (\upsilon /2)\sqrt{v\pi }}\). We have that \(\pi (\theta )=\int _{0}^{\infty }\pi (\theta |\tau ^{2})\pi (\tau ^{2})d\tau ^{2}\) and therefore the marginal prior as follows:

$$\begin{aligned} \pi (\theta )= \left\{ \begin{array}{ll} \beta ^{q}\nu /(\theta -\mu )^{q+1/2}2F1(p+q,q+1/2,(\upsilon +1)/2+p+q,1-\beta \nu /(\theta -\mu )^{2}) &{}\quad \text {if}\;\theta \ne \mu , \\ k_{1}\text {Be}(q+1/2,p+v/2)/\text {Be}(p,q) &{} \quad \text {if}\; \theta =\mu , \end{array}\right. \end{aligned}$$

with 2F1(abcz) the hypergeometric function (see 15.1.1 of Abramowitz and Stegun 1970) and we have that \(\pi (\theta )\) is the Student-t-Beta(\(\upsilon ,p,q,\beta\)) (see Fúquene et al. 2014 for the proof of this result). The variances of the RBDM are Student-t-Beta\((\upsilon ,q,p,\frac{1}{\beta })\) densities (with the Beta2 prior for the precision as \(\lambda =1/\tau ^{2}\)). Here \(W_{t,i}\) denotes the ith diagonal element of \(W_{t,i}\), \(i=1,\ldots ,n\) the hierarchical Student-t-Beta(\(\upsilon ,q,p,\frac{1}{\beta }\)) prior can be summarized as follows:

$$\begin{aligned} V_{t}^{-1}&=\lambda _{y}\omega _{y,t},\quad W_{t,i}^{-1}=\lambda _{\theta ,i}\omega _{\theta ,t_{i}},\\ \lambda _{y}|q&\sim \text {Gamma}(q,(\beta \rho _{y})^{-1}),\quad\lambda _{\theta ,i}|q\sim \text {Gamma}(q,(\beta \rho _{\theta ,t_{i}})^{-1}),\\ \omega _{y,t}&\sim \text {Gamma}(\upsilon /2,2/\upsilon ),\quad\omega _{\theta ,t_{i}}\sim \text {Gamma}(\upsilon /2,2/\upsilon ),\\ \rho _{y}&\sim \text {Gamma}(p,1),\quad\rho_{\theta ,t_{i}}\sim \text {Gamma}(p,1), \end{aligned}$$

For each t, the posterior distribution of the latent variables \(\omega _{y,t}\) and \(\omega _{\theta ,t_{i}}\) is useful in order to account the outliers and abrupt changes in the economic time series. Values of \(\omega _{y,t}\) and \(\omega _{\theta ,t_{i}}\) smaller than one indicate possible outliers or abrupt changes respectively. A Gibbs sampler scheme can be implemented by using the full conditional in closed form of RBDMs (see Appendix 1).

2.1 Illustration RBDM with a toy example: the annual CPI from Puerto Rico

We consider now the annual Consumer Price Index (CPI) in Puerto in the log-scale in order to illustrate how a RBDM works. We use a local linear trend model (i.e., linear growth model) for fitting the trend and slope of the Consumer CPI in logarithm scale as follows:

$$\begin{aligned} y_{t}&=\mu _{t}+\nu _{t},\quad \nu _{t}\sim N(0,V_{t}), \nonumber \\ \mu _{t}&=\mu _{t-1}+\xi _{t-1}+\omega _{t,1},\quad \omega _{t,1}\sim N(0,W_{t,1}), \\ \xi _{t}&=\xi _{t-1}+\omega _{t,2},\quad\omega _{t,2}\sim N(0,W_{t,2}), \end{aligned}$$

with uncorrelated errors \(\nu _{t}\), \(\omega _{t,1}\) and \(\omega _{t,2}\) and where

$$\begin{aligned} \theta _{t}&=\left[ \begin{array}{c} \mu _{t}\\ \xi _{t} \end{array}\right] ,\quad G=\left[ \begin{array}{cc} 1 &{} 1\\ 0 &{} 1 \end{array}\right] ,\quad W_{t}=\left[ \begin{array}{cc} \sigma ^{2}_{\mu ,t} &{} 0\\ 0 &{} \sigma ^{2}_{\xi ,t} \end{array}\right] ,\quad F=\left[ \begin{array}{cc} 1&0 \end{array}\right] . \end{aligned}$$
Fig. 1
figure 1

Outliers and structural breaks in the annual logarithm Consumer Price Index in Puerto Rico using the robust approach. The right scale is for the latent \(\omega _{y,t}\) and \(\omega _{\theta ,t_{i}}\) parameters

For this toy example we use a Student-t-Beta2 where \(p=q=1\), and \(1/\beta =10{,}000\) as is proposed in Pericchi and Perez (2010). We have convergence of all parameters using 10,000 iterations after a burn-in phase period of 5000 iterations. Figure 1 displays how by using the RBDM an outlier in the year 2000 is obtained. The changes in the trend shows the level changes in 1990 and 2001 and the slope presents a change in 2003 (Fig. 1).

3 The case of Mexico

In this section we use a random walk RBDM in order to detect outliers and structural breaks of the inflation in Mexico. We use the monthly logarithm of the CPI-variations from 1696 to 1983 in order to accounting possible changes in inflation in Mexico during this period such as: (1) The monetary devaluation in 1976 and 1982. (2) The value-added tax imposed in 1980 with the posterior modification in 1983. (3) Some changes in the payment to employees and the increase in gasoline prices and (4) The modification in the economy in Mexico in 1983. The random walk model RBDM can be written as follows:

$$\begin{aligned} y_{t}&=\theta _{t}+\nu _{t},\quad \nu _{t}\sim N(0,V_{t}), \nonumber \\ \theta _{t}&=\theta _{t-1}+\omega _{t},\quad \omega _{t,1}\sim N(0,W_{t}), \end{aligned}$$

with the prior specification showed in previous Section. We implement the Gibbs sampling scheme showed in Appendix 1 and from a visual assessment of the Gibbs output we have that convergence has been achieved in Appendix 2. The ergodic means are nonetheless pretty stable in the middle of the plots and the decay of the empirical autocorrelation function is very fast.

Fig. 2
figure 2

Outliers and structural breaks in CPI-variations from Mexico 1969–1983. The right scale is for the latent \(\omega _{y,t}\) and \(\omega _{\theta ,t_{i}}\) parameters. Red points illustrate the outliers and structural breaks (color figure online)

Table 1 Posterior mean of \(\omega _{y,t}\) for the monthly CPI-variations from Mexico 1969–1983

According to Fig. 2. The state parameters show significant level changes in September 1976 and January 1982. These changes likely represent the exchange rate devaluation in September 1976 and just one month before of the second devaluation in 1982. On the other hand, in Table 1 the expectations for the latent parameters for identifying the outliers in the random walk RBDM are presented. The outliers in January 1980 and January 1983 probably showed the value-added tax imposed and consequently modified in those dates with also the modification in the economy in Mexico in 1983. The most dramatic increase in payment to employees could be exposed for the extreme values in January 1974, October 1976 and January 1979. The exchange rate devaluation presented in August 1982 and December 1982 are also presented in Table 1. Due to the increase in gasoline prices the RBDM could show outliers in December 1973, November 1974 and November 1976. Finally, we think this random walk RBDM could be useful not only to accounting changes in this economic time series but also may be useful as an pre-intervention dynamic model.

4 The case of Puerto Rico

In this section we use the linear trend RBDM presented in (6) and a linear trend RBDM with a seasonal component in order to model the logarithm of CPI, AEI and total number of employments (TNE) from January 1980 to December 2012 in Puerto Rico. The CPI and Economic Activity Index (EAI) are two economic indexes widely used for describing the economic situation of Puerto Rico. The CPI and EAI are useful for accounting the inflation through of price fluctuations and the real economic activity. EAI and TNE are very correlated in the sense that EAI is computed by using also TNE. However TNE is an interesting time series for the quarterly seasonal component and also for the historic fact that in Puerto Rico in July 2009 near of 17,000 employments lost their jobs for the recent economic crisis. We find that by using RBDMs historical changes are detected as structural breaks in the trend of the models.

Now we describe briefly some of the important historical changes useful for the interpretation of the results.

4.1 CPI historical changes

A first index for accounting the inflation in Puerto Rico was born by using the cost of living for working families in 1940. The CPI was born in 1977 by including in the first index information on urban families, self-employed and the pensioners in Puerto Rico. Using addition products, in 1990 a few adjustments to items and services of CPI were proposed. A new study of Income and Expenses was made in the years 1999–2003 with a major change in the CPI methodology in March 2010. Currently, the basket of goods for CPI has the following major groups: food and beverages, housing, apparel, transportation, medical care, entertainment, education and communication and those groups are similar to the United States basket (see for example Department of labor and human resources 2008).

4.2 EAI historical changes

The monthly EAI includes the behavior of four economic indicators: total number of employments (thousands), cement sales (million bags), fuel consumption (millions of gallons) and electricity generation (million KWH). According to the Government Development Bank for Puerto Rico (2012) the EAI has a strong linear correlation of 0.97 with the gross national product (GNP). So, in this work we use EAI as one of the indicators useful for detecting recession periods in the economy of Puerto Rico during the last 35 years have been: 1980–1982, 1990–1991, 2001–2002 and since 2006.

Fig. 3
figure 3

Economic time series from Puerto Rico: EAI, CPI and TNE

Due to the quarterly seasonal component in TNE (see Fig. 3) we use a local trend with a seasonal component in this economic variable. The observation and system matrices of this model are:

$$\begin{aligned} F&=\left[ \begin{array}{ccccc} 1&0&1&0&0 \end{array}\right] \quad G=\left[ \begin{array}{ccccc} 1 &{} 1 &{} 0 &{} 0 &{} 0\\ 0 &{} 1 &{} 0 &{} 0 &{} 0\\ 0 &{} 0 &{} -1 &{} -1&{} -1\\ 0 &{} 0 &{} 1 &{} 0 &{} 0\\ 0 &{} 0 &{} 0 &{} 1 &{} 0 \end{array}\right] , \end{aligned}$$

and the unknown parameters are the observations variance \(V_{t}\) and three elements for \(W_{t}\):

$$\begin{aligned} W_{t}=\left[ \begin{array}{ccccc} \sigma ^{2}_{\mu ,t},&\sigma ^{2}_{\xi ,t},&\sigma ^{2}_{s,t},&0,&0 \end{array} \right] \end{aligned}$$

where \(\sigma ^{2}_{\mu ,t}\), \(\sigma ^{2}_{\xi ,t}\) and \(\sigma ^{2}_{s,t}\) are the unknown variances of the level of the series, the slope of the linear trend and the seasonal respectively.

Fig. 4
figure 4

Outliers and structural breaks in the logarithm monthly Consumer Price Index in Puerto Rico. The right scale is for the latent \(\omega _{y,t}\) and \(\omega _{\theta ,t_{i}}\) parameters. Red points illustrate the outliers and structural breaks (color figure online)

Fig. 5
figure 5

Outliers and structural breaks in the logarithm monthly Economic Activity Index in Puerto Rico. The right scale is for the latent \(\omega _{y,t}\) and \(\omega _{\theta ,t_{i}}\) parameters. Red points illustrate the outliers and structural breaks (color figure online)

Figure 4 displays the results by using CPI for the period of January 1980–December 2012. The residuals in bottom of Fig. 4 are given by \(\hat{\epsilon }_{t}=y_{t}-E(F\theta _{t}|y_{1:T})\). By looking at the residuals there are no outliers. The slope is dynamically changing with only a sudden jump within the first recession period in September 1981.

Fig. 6
figure 6

Trend, slope and seasonal posterior mean parameters with their corresponding credible interval for TNE

Table 2 show how the trend has different jumps, the most dramatic one in September 2005 with \(E(\omega _{\theta ,t_{1}}|y_{1:T})=0.07\) and some other abrupt changes in the precedent years. Even though the CPI is an indicator of inflation, this dramatic change could have been an “alarm” for the economic recession Puerto Rico is facing since 2006. Other dramatic changes are found in May 1980, July 1989 and September 1990, all of them within of recession periods in Puerto Rico.

The structural break in 1980 likely is due to changes in the methodology for computing the CPI. The change in the trend of the CPI at the years 1989 and 1990 could also be related to the implementation of the “Joint Committee on Taxation” in the United States, and its effect on the island. Figure 5 shows the abrupt changes in the trend for the EAI.

Table 2 Posterior mean of \(\omega _{\theta ,t_{1}}\) for the monthly logarithm of the CPI, EAI and TNE

In particular, two dramatic level changes are presented in September 1989 and December 1989 in the beginning of the recession period of 1990. On the other hand other structural breaks are showed in July 1996, September 1998, December 1998 and July 2005 probably related with the rest of recession periods.

Fig. 7
figure 7

Comparison structural breaks for the monthly Consumer Price and Economic Indexes in Puerto Rico. The right scale is for the latent \(\omega _{\theta ,t_{1}}\) parameter. Red points illustrate the outliers and structural breaks. Red lines divide the recession time periods (color figure online)

Figure 6 illustrates the trend, slope and seasonal posterior component with their corresponding credible intervals for TNE. An interesting feature by using RBDMs is that the credible intervals are not of constant width. For the seasonal component the 95 % interval is wider for the structural changes. Figure 7 displays the relationship between the time series for the recession periods. The abrupt changes in both indexes during the last period may be the consequence of the economic crisis that Puerto Rico has been suffering since 2006. In the recent economic crisis in Puerto Rico 7816 public employments lost their jobs in July 2009 and the RBDM detects this change in the bottom of Fig. 7.

5 Conclusions

In this paper we apply Robust Bayesian Dynamic Models (RMBDs) to Latin-American time series from Mexico and Puerto Rico. The classes of RMBDs presented in this work with weakly-robust priors for the observation and state variances consider most of the empirical models used in the classical econometrics literature as random walk, linear trend, seasonal and a combination of those models. We found that using RMBDs allow us to account historic outliers and structural breaks in the inflation in Mexico and the economic recession periods in Puerto Rico. In fact, the structural changes have a contextual historical and economical meaning. Also, the model has the feature of producing not constant credible intervals over time even after accounting for boundary effects in the Latin-American variables. Finally we consider that in a future work new RMBDs could be implement to time series with weakly-shrinkage priors for the observation and state variances as is the case of generalized autoregressive conditional heteroscedasticity (GARCH) models for dynamic volatility approaches in finance.