helske / KFAS

KFAS: R Package for Exponential Family State Space Models
64 stars 17 forks source link

NA value in standardised state residual at level shift #54

Closed suprajamalladi closed 3 years ago

suprajamalladi commented 3 years ago

hi, whenever i introduce a level shift in the model, all the standardised state residuals show up and the one exactly before the point where there is a level shift is NA, due to which there is a gap in the graph. I have highlighted the level residual in september which is NA and a level shift was introduced in October. the graph is attached to for your reference where there is a huge gap in september 2001.

Capture2

Capture

suprajamalladi commented 3 years ago

i have also tried using P1inf=0, P1=100 in the model and it is still the same

helske commented 3 years ago

Hmm, this looks strange. Can you provide a reproducible example (with fake data if necessary)?

suprajamalladi commented 3 years ago

I am sorry about the confusion, there is no gap when P1inf=0 and P1=100 is mentioned, and there is a gap without it. Do you still need my code and example?

helske commented 3 years ago

Ok this has probably something to do with the end of diffuse initialization. If you change the tol parameter of your model to zero or say 1-e4 (model$tol <- 0 or model$tol <- 1e-4) do the results change?

suprajamalladi commented 3 years ago

Thank you for your response. Yes I got gaps in the residual plot when I changed the tolerance value to 1e-4 and removed p1,p1inf and no gaps with tolerance =0 but this warning message: **Warning message: In KFS(kfasfit1$model, filtering = c("state"), smoothing = c("state", : Possible error in smoothing: Negative variances in V, check the model or try changing the tolerance parameter tol or P1/P1inf of the model.

**

helske commented 3 years ago

Sorry, been really busy with other stuff and I completely missed your reply to this. I think I would need code and the corresponding data for figuring out what is going on here, as I have not seen this kind of behaviour earlier.