LOCALDLMINIT Procedure |
@LocalDLMInit provides rough estimates of the component variances for the irregular and trend rate variances for a local level or local trend model, possibly in the presence of seasonals.
@LocalDLMInit(options) series start end
Parameters
|
series |
observable series |
|
start, end |
range over which to compute approximate variables. By default, the defined range of series. |
Options
DESEASONALIZE/[NODEASONALIZE]
chooses whether to remove seasonal (by regression on dummies) first.
IRREGULAR=(output) estimate of the irregular (measurement error) variance
TREND=(output) estimate of the trend rate variance
Example
This does a local trend state-space model of log GDP, first by using the Hodrick-Prescott filter (which is a special case with a specific variance ratio), then by freely estimating the component variances. For the latter, @LocalDLM is used to set up the system matrices for the state-space model, then @LocalDLMInit is used to get preliminary estimates of the variances. DLM does the actual estimation.
*
* Martin, Hurn, Harris, "Econometric Modelling with Time Series"
* Application 15.8.1, from pp 567-571
* Hodrick-Prescott filter
*
open data "usgdp.dat"
calendar(q) 1940:1
data(format=prn,nolabels,org=columns) 1940:01 2000:01 usgdp
*
set logy = 100.0*log(usgdp)
*
* This is how you would HP-filter a data series using RATS
*
filter(type=hp) logy / hplogy
graph(footer="Figure 15.4 Log of GDP with smoothed trend component",$
key=upleft,klabels=||"Smoothed","Actual"||) 2
# hplogy 1940:1 1952:4
# logy 1940:1 1952:4
*
* This does the analysis by Kalman filtering
*
@localdlm(type=trend,shocks=trend,a=a,c=c,f=f)
@localdlminit(trend=sigsqzeta,irreg=sigsqc) logy
*
* Freely estimate both component variances
*
nonlin sigc sigzeta
compute sigc=sqrt(sigsqc),sigzeta=sqrt(sigsqzeta)
dlm(presample=diffuse,a=a,c=c,f=f,sv=sigc^2,sw=sigzeta^2,y=logy,type=smooth,$
method=bfgs) / xstates
Copyright © 2025 Thomas A. Doan