Displaying 2 results from an estimated 2 matches for "dlmmodsea".
Did you mean:
dlmmodseas
2011 Nov 18
0
Kalman Filter with dlm
I have built a Kalman Filter model for flu forecasting as shown below.
Y - Target Variable X1 - Predictor1 X2 - Predictor2
While forecasting into the future, I will NOT have data for all three
variables. So, I am predicting X1 and X2 using two Kalman filters. The code
is below
x1.model <- dlmModSeas(52) + dlmModPoly(1, dV=5, dW=10)
x2.model <- dlmModSeas(52) + dlmModPoly(1, dV=10, dW=10)
x1.filter <- dlmFilter(c(train$x1, rep(NA, noofsteps)), x1.model)
x2.filter <- dlmFilter(c(train$x2, rep(NA, noofsteps)), x2.model)
Now, I am forecasting Y using the predicted X1 and X2 as bel...
2012 Jan 23
0
problems with dlmBSample of the dlm package
...?
This is the code:
function (orig_ts){
library(dlm)
dV_T <- 20000
dW_T <- c(100,10)
m0_T <- rep(0,2)
C0_T <- 10000*diag(nrow=2)
my_dlmModPoly <- dlmModPoly(order=2, dV_T, dW_T, m0_T, C0_T)
dV_S <- 20000
dW_S <- c(500,0,0)
m0_S <- rep(0,3)
C0_S <- 10000*diag(nrow=3)
my_dlmModSeas <- dlmModSeas(frequency=4, dV_S, dW_S, m0_S, C0_S)
my_mod <- my_dlmModPoly + my_dlmModSeas
my_dlmFilter <- dlmFilter(orig_ts, my_mod)
my_dlmBSample <- dlmBSample(my_dlmFilter[-1])
plot(orig_ts, type = 'o', ylim=c(-200, 550))
lines(my_dlmFilter$f[-1], col=2)
lines(my_dlmFilte...