Spanish Industrial Production Index with UComp

Diego J. Pedregal


#> Loading required package: Rcpp

Here there are some examples run with package UComp, for the automatic modelling of Unobserved Components models a la Harvey (1989). The absolute novelty of this package is that it provides an automatic identification of UC models, though particular models may be estimated, if desired. The package also perform outlier detection, may identify cycles of period longer than one year and allows for models with exogenous inputs.

The library is composed of just a few functions to perform a comprehensive analysis of time series:

The inputs to UC, UCsetup and UCmodel are the same and control how the rest of functions work (check the manual and examples below).

Now, the examples. First, just load the library and some data (monthly Spanish industrial production index) from January 2000 to December 2019. the last year of data is reserved to check forecasting performance.

ipi = ts(y[1 : 208], start = 2000, frequency = 12)

The call could be as simple as the next to estimate the optimal model and plot the components. The output shows the estimated models with their information criteria values and the table with the estimates and some diagnostics tests.

m = UC(log(ipi))

A different call, more complex, would be as follows (just one model is estimated, the forecasting horizon is fixed at 24 months, verbose output is avoided, see the full set of options in the documentation). As can be easily seen, the diagnostics tests indicate that this model is completely inappropriate:

m = UC(log(ipi), model = "rw/equal/arma(0,0)", h = 24, verbose = FALSE)

Something that is very interesting in this case is the estimation with Easter and calendar effects (already loaded in matrix u) and with outlier detection. Check out the diagnostics and now to see that this model is much more adequate:

m = UC(log(ipi), u = u, outlier = 4)

Beta(1) and Beta(2) are the parameter estimates for Easter and the calendar effects and there is one oulier detected in observations 108 as a level shift.

Finally, forecasts and their variances are stored in fields yFor and yForV, respectively. The following plot shows forecasts and their 95% confidence bands.

plot(m$yFor, ylim = c(4.3, 4.85))
lines(m$yFor + 2 * sqrt(m$yForV), col = "red")
lines(m$yFor - 2 * sqrt(m$yForV), col = "red")