State space model with seasonal components
Posted: Mon Jul 06, 2009 4:06 am
First thank you very much for solving my past questions.
I have a question of incoporating seasonal components into state space model and estimate them by DLM in RATS. My question is as follows:
I have monthly data of a series named FDI, and I select s=12, so if I want to incorporate a random walk component, a slope component and an AR(1) component into the state vector, I will have a state vector which has 14 elements, among these 14, 11 elements would be seasonal components.
The question I have is, if I only have three elements in the state vectors, to define matrices in 3 by 3 form is relatively easy, as my previous programme shows:
"environment noecho
*input datafile
open data FDIF_M_97_09.xls
data(format=xls,org=colulmns) / FDI
calendar(m) 1997:01
all 2009:03
*initialize the variables and matrices
nonlin v1 v2 v3
frml M3 = v1/sqrt(1+v1*v1)
frml Q1 = exp(v2)
frml Q3 = exp(v3)
dec rect z
dec rect h
*dec vect g
dec frml[rect] M
dec frml[symm] Q
dec frml[vect] f
compute z = ||1.0|0.0|1.0||
compute g = ||0.0|0.0|1.0||
compute h = 1.0
frml M = ||1.0,1.0,0.0|0.0,1.0,0.0|0.0,0.0,M3||
frml Q = ||Q1,0.0,0.0|0.0,0.0,0.0|0.0,0.0,Q3||
frml f = ||FDI||
"
And now, if I want to incorporate seasonal component into the state space model, I will have the matrices M, Q as 14 by 14, g as 14 by 1. Instead of writing them explicitly, which apparently will cost a huge space in programme file, I just wonder if there is an easy way to write these matrices in a compact way (as what we could have done in MATLAB or other software.), But I tried a lot and it does not work.
May I ask if you could give me some hint on this problem?
Thank you very much!
I have a question of incoporating seasonal components into state space model and estimate them by DLM in RATS. My question is as follows:
I have monthly data of a series named FDI, and I select s=12, so if I want to incorporate a random walk component, a slope component and an AR(1) component into the state vector, I will have a state vector which has 14 elements, among these 14, 11 elements would be seasonal components.
The question I have is, if I only have three elements in the state vectors, to define matrices in 3 by 3 form is relatively easy, as my previous programme shows:
"environment noecho
*input datafile
open data FDIF_M_97_09.xls
data(format=xls,org=colulmns) / FDI
calendar(m) 1997:01
all 2009:03
*initialize the variables and matrices
nonlin v1 v2 v3
frml M3 = v1/sqrt(1+v1*v1)
frml Q1 = exp(v2)
frml Q3 = exp(v3)
dec rect z
dec rect h
*dec vect g
dec frml[rect] M
dec frml[symm] Q
dec frml[vect] f
compute z = ||1.0|0.0|1.0||
compute g = ||0.0|0.0|1.0||
compute h = 1.0
frml M = ||1.0,1.0,0.0|0.0,1.0,0.0|0.0,0.0,M3||
frml Q = ||Q1,0.0,0.0|0.0,0.0,0.0|0.0,0.0,Q3||
frml f = ||FDI||
"
And now, if I want to incorporate seasonal component into the state space model, I will have the matrices M, Q as 14 by 14, g as 14 by 1. Instead of writing them explicitly, which apparently will cost a huge space in programme file, I just wonder if there is an easy way to write these matrices in a compact way (as what we could have done in MATLAB or other software.), But I tried a lot and it does not work.
May I ask if you could give me some hint on this problem?
Thank you very much!