# NOT RUN {
## SIMULATED EXAMPLE
t <- seq(0.05, 5, by = 0.05)
t2 <- seq(0.05, 6, by = 0.05)
p = length(t2)-length(t) # Forecasting horizon parameter:
n = length(t)
Y <- cbind(t^3 - 9 * t^2 + 23 * t + rnorm(n, 0, 1),
10 * sin(3 * t) / t + rnorm(n, 0, 1))
y <- mtsframe(dates = t, Y)
fit.vertical <- msst(y)
pred.vertical <- predict(fit.vertical, p = p)
print(pred.vertical$forecast)
## BREXIT DATA EXAMPLE
## (de Carvalho and Martos, 2018; Fig. 1)
data(brexit)
attach(brexit)
y <- mtsframe(date, brexit[, 1:3] / 100)
fit <- msst(y)
## Window length and components automatically selected
fit$l; fit$m
## Plot trendlines (de Carvalho and Martos, 2018; Fig. 1)
plot(fit, options = list(type = "trendlines"), xlab="time",
col=c("blue", "red", "black"), lwd = 2, lty = c(1, 2, 3))
## Plot cumulative periodograms (with 95% confidence bands)
par(mfrow = c(1, 3))
plot(fit, options = list(type = "cpgrams",
series.names = c('Leave','Stay','Undecided')) )
## Scree-plot
par(mfrow = c(1, 1))
plot(fit, options = list(type = "screeplot", ncomp.scree = 1:10),
type = "b", pch = 20, lwd = 2, main='Scree plot')
## Plot elementary reconstructed components
plot(fit, options = list(type = "components", ncomp = 1:2))
# }
Run the code above in your browser using DataLab