Open eeholmes opened 4 years ago
MARSSkfas(kemfit, return.lag.one=FALSE)$VtT[,,1:2]
is the same so not in the stack part of code.
Happens with tinitx=1 or tinitx=0
Not a bug per se but numerical inaccuracy in the classic Kalman filter. When Z is a column vector, an inversion of
Z %*% Vtt1 %*% t(Z) + R
is done. If Vtt1 is much larger than R then that is ill-conditioned. With V0 = 10000, Vtt1 at t=1 is much larger than R and this is ill-conditioned.
MARSSkfss is not used in the fitting functions. Addressed by changing the default kf function in the residuals to use MARSSkfas.
Good enough. Part of the numerical problems with the classic filter/smoother. Avoid making the V0 so bad by not trying to make it diffuse.
Try this for Kt[,,1] which worked for the V0T problem
solve(t(Vtt1[,,1]), B%*%V00)
Version 3.11.5 Info 9/27/2021
This is completed but before closing completely do the following.
V0!=0
if that is missing.MARSSinfo()
and check entry for V0!=0-Bug. Only made it happen for Z as column vector with V0 non-zero. Guessing it is in MARSSkfss() and seems to be in the smoother part.
Gives
With Z identity, ok