TMB crashing R
Closed this issue · 1 comments
What is the most common cause of TMB crashing R when calling the function to optimize?
There's three types of errors typically:
-
compile errors -- these occur when running
TMB::compile
, and the error message usually lists a line number and is easy to find and fix -
build errors -- these occur during
TMB::BuildADFun
, and typically occur because you have a loop that exceeds the dimensionality of a vector/matrix/array. These are harder to find on windows than other OS, because it crashes R. You can fix by using a debugger (hard on windows), or commenting out lines in batches to find the offending loop. -
inner loop errors -- these occur during the (typically first) inner optimizer call, and often arise because some random effect has a gradient of zero, such that the inner-hessian is not positive definite
-
outer loop errors -- these most often happen when the hessian for fixed effects is not positive definite at the MLE, due to some non-identifiable or non-estimable parameter.
Issues 3-4 you can check by, respectively, turning off the random effects or integrating them out, extracting the Hessian, getting its eigendecomposition, and inspecting the eigenvectors associated with zero-valued eigenvalues.