I would like to use the Kalman filter to predict price levels in some financial data of time series. Some search engines led me to several functions in R, namely StructTS and KalmanForecast. I am currently using StructTS to fit a model to a subset of the data, and then using a fitted model to predict several days in the future. The problem I am facing is that the model is not suitable. Am I not sure right now that I am training the model incorrectly? Or if the model does not converge with optimization?
My code and sample output are shown below:
alsi <- read.csv("http://www.turingfinance.com/wp-content/uploads/2015/11/ALSI.csv")
alsi <- as.vector(t(alsi['ALSI']))
kDays <- length(alsi)
kDays.sample <- as.integer(kDays*0.9)
alsi.train <- alsi[1:kDays.sample]
alsi.test <- alsi[kDays.sample:kDays]
fitted.model <- StructTS(alsi.train, type = "level")
alsi.test.forecast <- KalmanForecast(n.ahead = length(alsi.test), mod = fitted.model$model)
plot.ts(alsi.test, col = 'blue')
lines(alsi.test.forecast$pred, col = 'red')
alsi.train.forecast <- KalmanForecast(n.ahead = length(alsi.train), mod = fitted.model$model)
plot.ts(alsi.train, col = 'blue')
lines(alsi.train.forecast$pred, col = 'red')

, . Google, , R ?KalmanLike ?StructTS. . !
- Kalman Filters R , , :
Kalman Filtering in R ( )