Kalman Filter
Posted: Mon Jan 10, 2011 12:49 am
Dear Friends,
I have some questions need your help.
For example, we need to estimate a model
Y(t)= B(t)*X(t)+v
and assume B(t) follow simple transitional process
B(t)=aB(t-1)+u and assume the parameter A to be 1.
As to my understanding, we should use the following code:
Question: Am I doing the correct staff?
The RATS book says that the function RLS do recursive estimation using kalman filter , then I run as follows,
but the results are different. May I know why?
As curiosity, I also estimated rolling coefficients as follows:
The results from this estimation is exactly same as from RLS which is based on Kalman filter. I am wondering so what is the purpose to have RLS if it does not improve anything better than simple rolling estimate.
Then I did the following:
Is there anyone can help to clarify the difference of all these? Your kind help on these matters are highly appreciated.
[/size]
I have some questions need your help.
For example, we need to estimate a model
Y(t)= B(t)*X(t)+v
and assume B(t) follow simple transitional process
B(t)=aB(t-1)+u and assume the parameter A to be 1.
As to my understanding, we should use the following code:
Code: Select all
compute sv=0.1**2,seta=0.02**2,seps=0.04**2
dlm(y=y,c=||1.0,x||,sv=sv,sw=%diag(||seta,seps||),exact,type=smoothed) / xstates vstates
*
linreg y
# constant x
*
set tv1 = xstates(t)(2)
graph(vgrid=%beta(2),footer="Smoothed estimates of time-varying coefficient")
# tv1The RATS book says that the function RLS do recursive estimation using kalman filter , then I run as follows,
Code: Select all
rls(cohistory=coefs) y
# constant x
graph(vgrid=%beta(2),footer="time-varying coefficien")
# coefs(2)As curiosity, I also estimated rolling coefficients as follows:
Code: Select all
set beta 1 98 =0
do i=3, 98
linreg(noprint) y 2 i
# constant x
com beta(i)=%beta(2)
end do
graph(vgrid=%beta(2),footer="time-varying coefficient")
# beta 3 *Then I did the following:
Code: Select all
Equation kalcoef y
# constant x
system kalcoef
end(system)
estimate(cohistory=cokalman) 1 10
do entry=11, 98
kalman(cohistory=cokalman) 3
end do entry
graph(vgrid=%beta(2),footer="time-varying coefficient")
# cokalman(2) 3 *
[/size]