[R] loops in R help me please
rose bentosa
rbentosa at yahoo.com
Thu Feb 22 00:41:48 CET 2007
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
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070221/21004e1e/attachment.txt
More information about the R-help
mailing list