(Edit Aug 11, 2009 to fix a typo regarding the CP option)
- to the trend rate only, option SHOCKS=TREND (default)
- to the level only, option SHOCKS=LEVEL (underlying completely linear trend)
- to both, option SHOCKS=BOTH
- Code: Select all
*
* @LocalDLM(options)
*
* Creates the "A", "C" and "F" or "SW" matrices for a local level or
* local trend DLM.
*
* 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, or both. The variance
* on the shock to the level frequently estimates zero.
*
* This also supports an older syntax with A, C and SW *parameters*. They are
* A, C and SW in order. (SW=FF'). We recommend that you switch to the newer
* and more flexible setup.
*
* TYPE=LEVEL is the local level (random walk) model. This has one state (the local
* level). A, C and F are all just 1x1 unit matrices.
*
* TYPE=TREND is the local trend model. The two states are the local level and the
* local rate of change.
*
* 1 1 0 1 1 0
* A = C = [1 0] F = or F = or F =
* 1 0 1 0 0 1
*
* The first F is for the default of SHOCKS=TREND - just the shock to the
* trend rate. The second is for SHOCKS=LEVEL and the third for
* SHOCKS=BOTH. Note that in the last case, the shock to the level is
* first, and the shock to the trend is second.
*
* See Durbin and Koopman, "Time Series Analysis by State Space Methods", Oxford
* University Press 2001, page 10 and 39 for more information.
*
* Parameters (still supported, in order):
* A (output) the state transition matrix
* C (output) the coefficient matrix
* SW (output) the symmetric state disturbance matrix
* (shape only - you'll have to multiply by the component variance)
*
* Revision Schedule:
* 02/2007 Written by Tom Doan, Estima
* 07/2009 Revised to use options rather than parameters for output. Add F option
* and SHOCKS option.
*
procedure LocalDLM ap cp swp
type rect *ap *cp
type symm *swp
*
option choice type 1 level trend
option choice shocks 1 trend level both
option rect *a
option rect *c
option rect *f
*
if type==1 {
if %defined(ap)
compute ap=||1.0||
if %defined(a)
compute a=||1.0||
if %defined(c)
compute c=||1.0||
if %defined(cp)
compute cp=||1.0||
if %defined(swp)
compute swp=||1.0||
if %defined(f)
compute f=||1.0||
}
else
if type==2 {
if %defined(a)
compute a=||1.0,1.0|0.0,1.0||
if %defined(ap)
compute ap=||1.0,1.0|0.0,1.0||
if %defined(c)
compute c=||1.0|0.0||
if %defined(cp)
compute cp=||1.0|0.0||
if %defined(f) {
*
* Allow for separate shocks to the each component
*
if shocks==3
compute f=||1.0,0.0|0.0,1.0||
else
*
* Shock only to the trend rate (second componet)
*
if shocks==1
compute f=||0.0|1.0||
else
*
* Shock to the level component only
*
if shocks==2
compute f=||1.0|0.0||
}
if %defined(swp)
compute swp=||0.0|0.0,1.0||
}
end LocalDLM
