helske / KFAS

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

Order of columns of bivariate data for Poisson models #39

Closed mallerhand closed 5 years ago

mallerhand commented 5 years ago

Why do these two chunks give different results? Have I miss-specified?

model <- SSModel(cbind(DriversKilled, VanKilled) ~ SSMtrend(1, Q = matrix(NA,2,2)), data = Seatbelts, distribution = rep("poisson",2)) fit <- fitSSM(model, diag(c(-4,-4)), method = "BFGS") predict(fit$model)

model <- SSModel(cbind(VanKilled, DriversKilled) ~ SSMtrend(1, Q = matrix(NA,2,2)), data = Seatbelts, distribution = rep("poisson",2)) fit <- fitSSM(model, diag(c(-4,-4)), method = "BFGS") predict(fit$model)

helske commented 5 years ago

The initial values argument of fitSSM should a vector with length corresponding to the number of unknown parameters, i.e. 3 here (two variances and one covariance parameter). If you check fit$optim.out from your two cases you can see that they have converged to different values due to different initial values. If you use say c(-4,-4,0) for both you should get identical results.

mallerhand commented 5 years ago

thanks, issue resolved. I had passed a 2x2 matrix to inits instead of a 3-vector, forgetting the off-diagonal is the same one covariance, (not two).

Great stuff!


From: Jouni Helske notifications@github.com Sent: 10 September 2019 17:54 To: helske/KFAS KFAS@noreply.github.com Cc: ALLERHAND Michael michael.Allerhand@ed.ac.uk; Author author@noreply.github.com Subject: Re: [helske/KFAS] Order of columns of bivariate data for Poisson models (#39)

The initial values argument should a vector with length corresponding to the number of unknown parameters, i.e. 3 here (two variances and one covariance parameter). If you check fit$optim.out from your two cases you can see that they have converged to different values due to different initial values. If you use say c(-4,-4,0) for both you should get identical results.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/helske/KFAS/issues/39?email_source=notifications&email_token=AANG5ZZQRX5AX4AXJGI5EXTQI7GKRA5CNFSM4IVGSDKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6LY7HY#issuecomment-530026399, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AANG5Z3AJUWQHQJPYZ2RJSTQI7GKRANCNFSM4IVGSDKA.

The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.