dlrm: Dynamic linear regression model

Description Usage Arguments Details Value Author(s) References Examples

Description

Estimates a dynamic linear regression model by the Kalman filter/smoother and EM algorithm for parameter estimation.

Usage

1
2
3
4
5
dlrm(formula,data,maxit=100,ws,Sigma,A,Q,R,
Q.c=NULL,Sigma.c=Q.c,ntimes=NULL,tol=1e-5,
est.ws=TRUE,est.Sigma=TRUE,est.A=TRUE,est.Q=TRUE,est.R=TRUE,
filter.only=FALSE,verbose=FALSE,criterion=c("logLik","parameter"),
method="BFGS",hessian=FALSE,switch.LL=.5,switch.wait=5)

Arguments

formula

a formula specifying the regression model (regression coefficients vary over time).

data

(optional) data frame to evaluate the formula.

maxit

maximum number of iterations of the EM algorithm.

ws

a vector with (starting values) for the regression coefficients (defaults to 0)

Sigma

a matrix specyfing (starting values) of the covariance matrix of initial coefficients.

A

a matrix with (starting) values for the transition matrix of regression coefficients.

Q

a matrix with (starting) values for the covariance matrix of changes in the regression coefficients.

R

a matrix with (starting) values for the observational error covariance matrix.

Q.c

a binary matrix specifying whether elements of Q are freely estimable (value 1) or fixed (value 0)

Sigma.c

a binary matrix specifying whether elements of Sigma are freely estimable (value 1) or fixed (value 0)

ntimes

a numeric vector specifying the length of each repeated time series.

tol

tolerance level for the EM algorithm,

est.ws

(logical) estimate the values in ws?

est.Sigma

(logical) estimate the values in Sigma?

est.A

(logical) estimate the values in A?

est.Q

(logical) estimate the values in Q?

est.R

(logical) estimate the values in R?

filter.only

(logical) if TRUE, call returns the filtering estimates and does not estimate the (hyper-)parameters.

verbose

(logical) print information to the terminal about the iterations in the EM algorithm?

criterion

stopping criterion for the EM algorithm. If argument is "logLik" the algorithm stops if the abolute change in the log likelihood is smaller than argument "tol". If the argument is "parameter", the algorithm stops when the absolute change is smaller than argument "tol" for all estimated parameters.

method

method used in numerical optimization. See "optim" for details.

hessian

(logical) return the Hessian matrix of the parameter estimates?

switch.LL

value of logLik difference used when switching from EM to numerical optimization.

switch.wait

number of iterations before re-allowing numerical optimization.

Details

This function estimates a dynamic linear regression model via a combination of Expectation-Maximization (EM) and numerical optimization of the likelihood.

The model is for the (scalar) observations is

y[t] = x[t] * w[t] + e[t]

where e[t] is a Normally distributed variable with mean 0 and variance R. The model for the regression coefficients is

w[t] = w[t-1] + d[t]

where d[t] is a (multivariate) Normally distributed variable with mean 0 and covariance matrix Q.

The function computes the posterior distribution p(w_1:T|y_1:T,x_1:T) by the Kalman smoother.

Value

A list with estimated A, b, prior, etc.

Author(s)

Maarten Speekenbrink

References

Speekenbrink, M. \& Shanks, D.R. (2010). Learning in a changing environment. Journal of Experimental Psychology: General, 139, 266-298.

Examples

1
2
3
4
5
6
7
## open StockMarket Prediction Task data
data(SMPT)
mod <- dlrm(r ~ c1 + c2 - 1,data=SMPT,ws=c(0,0),Sigma=10*diag(2),
est.Sigma=FALSE,est.ws=FALSE,est.A=FALSE,Q=.005*diag(2),Q.c=diag(2),
ntimes=c(300,300),verbose=TRUE)
plot(mod$weight[1:300,1],type="l")
lines(mod$weight[301:600,1],col="red")

dlrm documentation built on May 2, 2019, 5:36 p.m.

Related to dlrm in dlrm...