SEASONALDLM Procedure |
@SEASONALDLM creates one of two state space representations for a seasonal. This is usually combined with a separate (independent) model for the mean, such as those generated by @LOCALDLM.
@SeasonalDLM( options )
Options
TYPE=[FOURIER]/ADDITIVE
TYPE=FOURIER models the seasonal states as cosine and sine waves at the harmonic frequencies of the seasonal (\(2\pi j/S\)), \(j = 1, \ldots ,S/2\), with no sine component when \(j = S/2\) for \(S\) even. The "C" vector adds up the cosine components. The amplitudes are independent random walks. This is usual the better form if the seasonal is driven by the weather.
TYPE=ADDITIVE models the seasonal states as additive components for each month (or quarter) which approximately add up to zero over the course of one year. The "C" vector extracts just the current month. This is usually the better form if the seasonal is driven by "calendar" effects (such as December vs January) rather than weather.
See Durbin and Koopman(2012), pp 48-49; West and Harrison(1997), chapter 8 for more information.
SPAN=seasonal span [CALENDAR seasonal]
A=(output) the state transition matrix
C=(output) the coefficient matrix
F=(output) the loadings from the state shocks to the states
TYPE=ADDITIVE has just one seasonal shock. TYPE=HARMONIC has seasonal span-1.
Example
This combines a local level model with an additive seasonal.
compute a=al~\as,f=fl~\fs,c=cl~~cs
is how you additively combine two independent component models to form an overall model. The combined model has two state shocks (one from the level and one from the additive seasonal).
*
* Commandeur & Koopman, An Introduction to State Space Time Series Analysis.
* Chapter 4, UK inflation data
*
open data ukinflation.txt
calendar(q) 1950
data(format=free,org=columns,skips=1) 1950:01 2001:04 ukinflation
*
* Rescaling data to percentages helps quite a bit by increasing the
* variances by a factor of 10^4.
*
set ukinflation = ukinflation*100.0
*
* Create the component models for the level and seasonal.
*
@LocalDLM(type=level,a=al,c=cl,f=fl)
@SeasonalDLM(type=additive,a=as,c=cs,f=fs)
*
* Glue them together to make the full system matrices
*
compute a=al~\as,f=fl~\fs,c=cl~~cs
*
@LocalDLMInit(deseasonalize,irreg=sigsqeps) ukinflation
*
* Same model with variances freed
*
nonlin sigsqeps sigsqxi sigsqomega
compute sigsqxi=sigsqeps*.01,sigsqomega=sigsqeps*.01
*
dlm(a=a,c=c,sv=sigsqeps,f=f,sw=%diag(||sigsqxi,sigsqomega||),exact,y=ukinflation,$
method=bfgs,vhat=vhat,svhat=svhat)
Copyright © 2026 Thomas A. Doan