LOCALDLM Procedure |
@LOCALDLM sets up the matrices for a local level or local trend state space model.
@LOCALDLM( options ) (no parameters)
Options
TYPE=[LEVEL]/TREND
A=(output) the state transition matrix
C=(output) the coefficient matrix
F=(output) the loadings from the state shocks to the states
SHOCKS=[TREND]/LEVEL/BOTH
For TYPE=TREND, this determines whether the state space model includes a shock to the trend rate, a shock to the level (very rare choice), or both. The variance on the shock to the level frequently estimates zero.
Description
For TYPE=LEVEL, the three matrices are the (rather simple)
\({\bf{A}} = [1],{\bf{C}} = [1],{\bf{F}} = [1]\)
For TYPE=TREND, they are
\({\bf{A}} = \left[ {\begin{array}{*{20}{c}}1 & 1 \\ 0 & 1 \\ \end{array}} \right],{\bf{C}} = \left[ {\begin{array}{*{20}{c}} 1 & 0 \\ \end{array}} \right],{\bf{F}} = \left[ {\begin{array}{*{20}{c}} 0 \\ 1 \\ \end{array}} \right],\left[ {\begin{array}{*{20}{c}} 1 \\ 0 \\ \end{array}} \right]\,{\rm{or}}\,\left[ {\begin{array}{*{20}{c}}1 & 0 \\ 0 & 1 \\ \end{array}} \right]\)
where the \({\bf{F}}\) matrices are for the SHOCKS=TREND, SHOCKS=LEVEL and SHOCKS=BOTH options in order. The third of these requires two shocks on the state vector, while all other models require just one.
Example
From Harvey(1989), pp 89-90
open data purse.prn
data(format=prn,org=cols) 1 71 purse
*
* Estimate the local trend model. We first do this unconstrained.
*
nonlin sigsqeta sigsqeps sigsqzeta
compute sigsqzeta=.001
@localdlm(type=trend,a=a,c=c,f=f,shocks=both)
dlm(a=a,c=c,sv=sigsqeps,y=purse,sw=%diag(||sigsqeta,sigsqzeta||),f=f,exact,$
method=bfgs)
*
* Since that gives us a negative variance for zeta, we re-estimate,
* imposing the positivity restriction.
*
nonlin sigsqeta sigsqeps sigsqzeta sigsqzeta>=0.0
dlm(a=a,c=c,sv=sigsqeps,y=purse,sw=%diag(||sigsqeta,sigsqzeta||),f=f,exact,$
method=bfgs)
Copyright © 2026 Thomas A. Doan