Learn R Programming

dlmodeler (version 1.4-2)

dlmodeler.build.polynomial: Build a polynomial model

Description

Builds an univariate polynomial DLM of the specified order.

Special cases: random walk, stochastic and deterministic levels and trends.

Usage

dlmodeler.polynomial(ord, sigmaH = NA, sigmaQ = 0, name = ifelse(ord==0,'level', ifelse(ord==1,'level+trend', 'polynomial')))
random.walk(name="random walk") stochastic.level(name="stochastic level") stochastic.trend(name="stochastic trend") deterministic.level(name="deterministic level") deterministic.trend(name="deterministic trend")
# old function name dlmodeler.build.polynomial(ord, sigmaH = NA, sigmaQ = 0, name = ifelse(ord==0,'level', ifelse(ord==1,'level+trend', 'polynomial')))

Arguments

ord
order of the polynomial ($0$ = constant, $1$ = linear, $2$ = cubic...).
sigmaH
std dev of the observation disturbance (if unknown, set to NA and use dlmodeler.fit to estimate it). Default = NA.
sigmaQ
std dev of the state disturbances (if unknown, set to NA and use dlmodeler.fit to estimate it). Default = 0.
name
an optional name to be given to the resulting DLM.

Value

An object of class dlmodeler representing the polynomial model.

Details

The polynomial term is of the form $a[1] + a[2]t + a[3]t^2 ... + a[ord]t^ord$.

The initial value P0inf is parametered to use exact diffuse initialisation (if supported by the back-end).

The deterministic level model is a special case of the polynomial model, where ord=0, sigmaH=0 and sigmaQ=0.

The deterministic trend model is a special case of the polynomial model, where ord=1, sigmaH=0 and sigmaQ=0.

The random walk, or stochastic level model, is a special case of the polynomial model, where ord=0, sigmaH=0 and sigmaQ=NA.

The stochastic trend model, is a special case of the polynomial model, where ord=1, sigmaH=0 and sigmaQ=NA.

References

Durbin, and Koopman, Time Series Analysis by State Space Methods, Oxford University Press (2001), pages 38-45.

See Also

dlmodeler, dlmodeler.build, dlmodeler.build.dseasonal, dlmodeler.build.tseasonal, dlmodeler.build.structural, dlmodeler.build.arima, dlmodeler.build.regression

Examples

Run this code
## Not run: 
# require(dlmodeler)
# 
# # generate some quarterly data
# n <- 80
# level <- 12
# sigma <- .75
# season <- c(5,6,8,2)
# y <- level + rep(season,n/4) + rnorm(n, mean=0, sd=sigma)
# 
# # deterministic level + quarterly seasonal + disturbance
# mod <- dlmodeler.build.polynomial(0,sigmaH=sigma) +
#        dlmodeler.build.dseasonal(4,sigmaH=0)
# f <- dlmodeler.filter(y, mod)
# 
# # show the one step ahead forecasts
# plot(y,type='l')
# lines(f$f[1,],col='light blue')
# ## End(Not run)

Run the code above in your browser using DataLab