library(tsbox) # remotes::install_github("christophsax/tsbox")
library(forecast)
library(seasonal)Monthly time series, with 4 to 5 years of data. Here, Monthly Deaths from Lung Diseases in the UK
ts_plot(mdeaths, fdeaths)Principal Component Decomposition, is easy, fast and powerful. Note that the sign is undefined, so I had to switch it for the graph.
ts_prcomp <- ts_(prcomp, predict, scale = TRUE)
core_trend <- ts_prcomp(ts_c(mdeaths, fdeaths))[,1]
ts_plot(ts_scale(ts_c(-core_trend, mdeaths, fdeaths)))This may be a more extended excercise. We may use some additional information here. E.g., overall sales projections, economic projections, etc. Or we could also specify some scenarios here, e.g., strong growth, weak growth etc.
Here, I am doing an exponential smoothing forecast, which is simply based on the history of the series
fm <- forecast(core_trend, h = 12)
plot(fm)core_trend_fct <- ts_rbind(core_trend, fm$mean)Note that the confidence intervalls are not valid anymore, because fm$mean is already an estimate.
One such 'core trend' could also be the number of trading days
m <- forecast(auto.arima(fdeaths, xreg = core_trend), xreg = fm$mean)
fdeaths_fct <- ts_rbind(fdeaths, m$mean)
plot(m)Using standard X-11 methodology
This already performs a standard trading day adjustment, but no significant effects have been found. Also performs automatic outlier detection.
plot(seas(fdeaths_fct, x11 = ""))



