[R-SIG-Finance] State Space Model + DLM Package in R
nserdar
snes1982 at hotmail.com
Tue Oct 30 11:36:42 CET 2012
Kalman filter approach is a special specification of state space model.
This is Kalman Filter random walk process code in DLM packages:
library(dlm)
buildCAPM<-function(u){
dlmModReg(rm,dV=exp(u[1]),dW=exp(u[2:3])) # rm market
}
outMLE<-dlmMLE(rt,parm=rep(0,3),buildCAPM) # rt return of indusrty
mod<-buildCAPM(outMLE$par)
outFilter<-dlmFilter(rt,mod)
mae<-mean(abs(outFilter$f)-rt) # MAE
mse<-mean(((outFilter$f)-rt)^2) #MSE
What I am asking how to modify this code as Kalman Filter Mean Reverting
For example:
R(it)= Alpha(it)+ Beta(it)R(mt)+ V(it)
KF Mean Reverting
Alpha(it)= Alphabar(i)+ phi* (Alpha(it-1)-Alphabar(i))+W(i1t)
Beta(it)= Betabar(i)+ phi* (Beta(it-1)-Betahabar(i))+W(i2t)
Please let me know if there is an any packages or codes how to employ
Kalman Filter with Mean Reverting.
Regards,
Serdar
--
View this message in context: http://r.789695.n4.nabble.com/State-Space-Model-DLM-Package-in-R-tp4647838.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list