Page 1 of 1

Simulating data series using DLM

Posted: Sat Oct 27, 2007 4:33 am
by Martin
Hi, I want to simulate a data series of Y that follows a state-space model:
Y=PI*S
S=M*S{1}+G*e,
where e has a identity variance-covariance matrix. I want RATS to start from S(0) as a zero vector, and simulate a Y data series. Here is what my program is and the outcome. But my simulated Y series is full of NA. What's wrong here? Thanks for your help. Best, Martin.

disp PI
0.19936 -0.19936 0.07611 -1.90270 0.00000
0.06879 -0.06879 0.03659 -0.11475 0.00000
0.00947 -0.00947 0.00878 -0.21954 0.00000
1.14430 -0.14433 0.04684 -1.81090 1.00000
0.08000 -0.08000 0.03200 0.00000 0.00000
0.00000 0.00000 0.00000 0.80000 0.00000
1.00000 0.00000 0.00000 0.00000 1.00000
disp M
1.50000 -0.50000 0.00000 0.00000 0.00000
1.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.80000 0.00000 0.00000
0.00000 0.00000 0.00000 0.80000 0.00000
0.00000 0.00000 0.00000 0.00000 0.80000

disp G
1.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 1.00000 0.00000
0.00000 1.00000 0.00000 0.00000
0.00000 0.00000 0.00000 1.00000
disp vm
1.00000 0.00000 0.00000 0.00000
0.00000 1.00000 0.00000 0.00000
0.00000 0.00000 1.00000 0.00000
0.00000 0.00000 0.00000 1.00000

all 200
dlm(c=tr(PI),a=M,f=G,type=simulate,yhat=y,sw=vm)

disp y(50)
NA NA NA NA NA NA NA

Posted: Mon Nov 05, 2007 1:51 pm
by TomDoan
There are a couple of small "workarounds" that you'll need to get this to work properly. Replace your DLM with:

Code: Select all

dlm(c=tr(PI),a=M,type=simulate,yhat=y,y=||1.0,1.0,1.0,1.0,1.0,1.0,1.0||,sw=g*tr(g)) / xstates
The "F" option (added with version 7) doesn't work properly with TYPE=SIMULATE or TYPE=CSIMULATE (which we didn't know until you posted this). So the SW option will have to provide a full 5x5 covariance matrix. (Don't worry about this being singular). The added Y=||....|| option (the value could be any 7-vector) is needed to convince TYPE=SIMULATE that you want the complete vector.

These are both due to bugs in 7.00 which will be fixed in version 7.1.