Description Usage Arguments Value Author(s) See Also Examples
Forecasting of a Gaussian state space model.
1 | forecast(ss, k=10)
|
ss |
an object of class |
k |
an integer specifying the number of time steps to be forecasted. |
The object ss
with updated components m
, C
and mu
.
Anette Luther Christensen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # Formulates Gaussian state space model
m1 <- SS(
Fmat = function(tt,x,phi){matrix(cos(2*pi*tt/365))},
Gmat = function(tt,x,phi){matrix(1)},
Wmat = function(tt,x,phi){matrix(phi)},
Vmat = function(tt,x,phi){matrix(0.1)},
phi = c(1e-1),
m0 = matrix(1),
C0 = matrix(100)
)
# Simulates observations
set.seed(984375)
m1 <- recursion(m1, 365)
plot(m1)
# Fits model
fit <- kfs(m1)
plot(fit)
# Change format of variances as these are time-invariant
fit$Wmat <- matrix(m1$phi)
fit$Vmat <- matrix(0.1)
# Estimates variances by use of EM algorithm
est.fit <- EMalgo(fit)
# Forecasting
fcast <- forecast(fit, k=100)
plot(fcast)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.