Learn R Programming

dlmodeler (version 1.4-2)

dlmodeler.build: Build a DLM

Description

Builds a DLM with the supplied design matrices, or an "empty" DLM of the specified dimensions.

Usage

dlmodeler.build(a0 = NULL, P0 = NULL, P0inf = NULL, Tt = NULL, Rt = NULL, Qt = NULL, Zt = NULL, Ht = NULL, dimensions = NULL, name = 'noname', components = list())

Arguments

a0
initial state vector.
P0
initial state covariance matrix.
P0inf
diffuse part of P0, matrix of zeros and ones.
Tt
state transition matrix.
Rt
state disturbance selection matrix.
Qt
state disturbance covariance matrix.
Zt
observation design matrix.
Ht
observation disturbance covariance matrix.
dimensions
vector of dimensions $(m,r,d)$.
name
an optional name to be given to the resulting DLM.
components
optional list of components.

Value

An object of class dlmodeler representing the model.

Details

A DLM can be constructed either by specifying all the elements a0, P0, P0inf,Tt, Rt, Qt, Zt and Ht or by simply giving the dimensions $m$, $r$ and $d$ (in which case the DLM is created with zero-filled elements of the appropriate dimension).

See dlmodeler for information about the state-space representation adopted in this package.

This function is called by the helper functions referenced below.

See Also

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

Examples

Run this code
## Not run: 
# require(dlmodeler)
# 
# # a stochastic level+trend DLM
# mod <- dlmodeler.build(
# 		a0 = c(0,0), # initial state: (level, trend)
# 		P0 = diag(c(0,0)), # initial state variance set to...
# 		P0inf = diag(2), # ...use exact diffuse initialization
# 		matrix(c(1,0,1,1),2,2), # state transition matrix
# 		diag(c(1,1)), # state disturbance selection matrix
# 		diag(c(.5,.05)), # state disturbance variance matrix
# 		matrix(c(1,0),1,2), # observation design matrix
# 		matrix(1,1,1) # observation disturbance variance matrix
# )
# # print the model
# mod
# # check if it is valid
# dlmodeler.check(mod)$status
# 
# # an empty DLM with 4 state variables (3 of which are stocastic)
# # and bi-variate observations
# mod <- dlmodeler.build(dimensions=c(4,3,2))
# # print the model
# mod
# # check if it is valid
# dlmodeler.check(mod)$status
# ## End(Not run)

Run the code above in your browser using DataLab