[R] loops in R help me please

rose bentosa
Wed, 21 Feb 2007 23:41:48 -0000

I am trying to make the following Kalman filter equations work and therefore
produce their graphs.
v_t=y_t - a_t
a_t+1=a_t+K_t*v_t
F_t=P_t+sigma.squared.epsilon
P_t+1=P_t*(1-K_t)+sigma.squared.eta
K_t=P_t/F_t

Given:
a_1=0,P_1=10^7,sigma.squared.epsilon=15099,
sigma.squared.eta=1469.1

I have attached my code,which of course doesnt work.It produces NAs for the
Fs,Ks and the a.
Can somebody tell me please what am I doing wrong in this loop?
Why doesnt this loop work as it should be;to produce  plots of a declining
filtered state variance(P_t),prediction errors(v_t),and a declining prediction
variance(F_t)?
Also,how can I construct and plot the 90% confidence intervals around a_t?
Thanks for your help and look forward.
Leonard



---------------------------------
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: kalmancodenotworking.txt