I want build a time varying coefficent model with a kalman filter.
I have take the programme tvarying which come from example in user guide chap 10.13.2....
but i must make some modification because my regressions is not a VAR and my process is a return to normaility process. so i have program this
Code: Select all
calendar 2000 1 1
allocate 2008:5
open data Sspace.xls
data(format=xls, org=obs) / *
table
compute kstart=2001:1,kend=2008:5
equation kalmeq returns
# constant vol_g dif_inf dif_tx var_re libor abcp swap stan_poo_vol gdpre_rate ratio_cap_gdp
declare vector b(11) bmean(11)
ewise bmean(i)=(i==2)
compute bmean=b
associate(perm) kalmeq b
linreg returns
# constant vol_g dif_inf dif_tx var_re libor abcp swap stan_poo_vol gdpre_rate ratio_cap_gdp
compute rseesq=.9*%seesq
system kalmeq
kfset(constant,noscale,likelihood=likely) xxx
#rseesq
tvarying tvx
end(system)
compute pi5 = .20**2
compute pi2 = .5**2
compute pi3 = 10000.
compute pi7 = 0.00000001
compute pi8 = 1.00
dim xxx(11,11) tvx(11,11)
*
compute likely=%const(0.0)
compute b=bmean
compute xxx=%const(0.0)
compute xxx(1,1)=pi5*pi3*rseesq
do i=1,4
compute decayfac=i**(2*.5)
compute xxx(i+1,i+1)=pi5*decayfac
compute xxx(i+5,i+5)=pi5*pi2*decayfac*rseesq
end do i
compute tvx=pi7*xxx
*
do time=kstart,kend
if time==kstart
kalman(start=time)
else {
compute b=pi8*b+(1-pi8)*bmean
compute xxx=(pi8**2)*xxx
kalman
}
end do time