Hi all -
We're working on fitting SPDE space (and time) models in TMB. We've done a bunch of comparisons against INLA and we're generally seeing pretty comparable modeling results. TMB also seems to have much faster fit times for large datasets.
I recently changed our code to allow for datapoints that aren't at mesh vertices. The results look good when the model fits correctly but we've been running into an issue where the covariance matrix from sdreport is not positive-definite (even after rounding). When the datpoints were constrained to be at mesh vertices we never ran into this issue.
To be explicit, these lines:
obj <- MakeADFun(...)
SD0 <- sdreport(obj, getReportCovariance=TRUE)
sigma <- SD0$cov
return a non-pos-def sigma. For larger simulated datasets this happens less often and the matrix isn't that far from pos-def (I can add a small number to the diagonal to make it pos-def). For smaller datasets this happens more often and the matrix may be quite far from pos-def (I may have to add diag(>5, nrow(sigma)) to sigma to make it PD).
Any suggestions/ideas/tips/advice on what might be going on and how to ensure that our VCOV matrix is PD?
We generate sigma to take joint draws from the fixed and random effects in order to simulate predictive maps and make inferences based on the draws.
Much thanks for all your awesome work in making this package available and for thinking about our question.
Cheers,
Aaron