dlmodeler.build.polynomial: Build a polynomial model

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Builds an univariate polynomial DLM of the specified order.

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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.

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.

Value

An object of class dlmodeler representing the polynomial model.

Note

State representations are generally not unique, so other forms could be used to achieve the same goals.

Author(s)

Cyrille Szymanski <cnszym@gmail.com>

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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)

Example output



dlmodeler documentation built on May 29, 2017, 11:33 a.m.