StructTS(x, type = c("level", "trend", "BSM"), init = NULL, fixed = NULL, optim.control = NULL)
frequency(x) > 1
, and a local trend
model otherwise. Can be abbreviated.NA
entries in
fixed
will be varied. Probably most useful for setting
variances to zero.optim
. Method "L-BFGS-B"
is used."StructTS"
with components:arima
nor different types of structural models.x
.x
.convergence
code returned by optim
.KalmanLike
. model0
is the
initial state of the filter, model
its final state.tsp
attributes of x
. The simplest model is the local level model specified by
type = "level"
. This has an underlying level $m[t]$ which
evolves by
The local linear trend model, type = "trend"
, has the same
measurement equation, but with a time-varying slope in the dynamics for
$m[t]$, given by
The basic structural model, type = "BSM"
, is a local
trend model with an additional seasonal component. Thus the measurement
equation is
Durbin, J. and Koopman, S. J. (2001) Time Series Analysis by State Space Methods. Oxford University Press.
Harvey, A. C. (1989) Forecasting, Structural Time Series Models and the Kalman Filter. Cambridge University Press.
Harvey, A. C. (1993) Time Series Models. 2nd Edition, Harvester Wheatsheaf.
KalmanLike
, tsSmooth
;
stl
for different kind of (seasonal) decomposition.
## see also JohnsonJohnson, Nile and AirPassengers
require(graphics)
trees <- window(treering, start = 0)
(fit <- StructTS(trees, type = "level"))
plot(trees)
lines(fitted(fit), col = "green")
tsdiag(fit)
(fit <- StructTS(log10(UKgas), type = "BSM"))
par(mfrow = c(4, 1)) # to give appropriate aspect ratio for next plot.
plot(log10(UKgas))
plot(cbind(fitted(fit), resids=resid(fit)), main = "UK gas consumption")
## keep some parameters fixed; trace optimizer:
StructTS(log10(UKgas), type = "BSM", fixed = c(0.1,0.001,NA,NA),
optim.control = list(trace = TRUE))
Run the code above in your browser using DataLab