Displaying 2 results from an estimated 2 matches for "dlmmod".
Did you mean:
lmmod
2011 Jun 03
0
How to reconcile Kalman filter result (by package dlm) with linear regression?
... L1[upper.tri(L1,T)] <- x[1:nMatrix]
return(dlm(
m0 = rep(0,nFactor),
C0 = diag(nFactor)*10,
FF = matrix(1,1,nFactor),
GG = diag(nFactor),
V = tail(x,1)^2,
W = crossprod(L1),
JFF = matrix(1:4,nr=1),
X = X
))
}
ModFit <- dlmMLE(Y,rep(0.1,nTotal),BuildMod,debug=T)
dlmMod <- BuildMod(ModFit$par)
V = dlmMod$V
W = dlmMod$W
m0 = dlmMod$m0
C0 = dlmMod$C0
ModFilt <- dlmFilter(Y,dlmMod)
v <- tail(dlmSvd2var(ModFilt$U.C,ModFilt$D.C),1)
m <- tail(ModFilt$m,1)
Here is the value of Y:
0.0125678739370109
-0.00241285475528163
0.00386919876129071
-0.00352839097...
2011 Jun 03
0
Package dlm generates unstable results?
...= a_{t-1} + noise(W)
I first run the following code: (I shall provide data at the end of the mail)
BuildMod <- function(x){
return(dlm(
m0 = x[1],
C0 = x[2],
FF = 1,
GG = 1,
V = x[3],
W = x[4],
JFF = 1,
X = X
))
}
ModFit <- dlmMLE(Y,rep(1,4),BuildMod,debug=T)
dlmMod <- BuildMod(ModFit$par)
V <- dlmMod$V
W <- dlmMod$W
ModFilt <- dlmFilter(Y,dlmMod)
v <- tail(dlmSvd2var(ModFilt$U.C,ModFilt$D.C),1)
m <- tail(ModFilt$m,1)
The results are:
V = 5.945003e-05
W = 0.0003086623
v = 9.850526e-05 (the estimated variance for a_t after we observe th...