How to identify variables that did not converge?
Leitemfa opened this issue · comments
Hello,
I'm using the gllvm, but got a warning on the lack of convergence. I would like to look at the MCMC values to see which variable(s) did not converge. How do I do that?
Is there any option to store the MCMC chains in the R object?
Thanks for your question! gllvm
approximates the integration in the likelihood, so no MCMC occurs and thus no chains are available (you can read e.g. https://besjournals.onlinelibrary.wiley.com/doi/full/10.1111/2041-210X.13303 for a few details). A first check (up to local optima in the likelihood surface) for convergence can be done based on the gradient, which is available in model$TMBfn$gr(model$TMBfn$par)
. The values of this vector should all be close to zero for a converged model. There is an automated way of doing this in the package, which is done by setting gradient.check = TRUE
in the main gllvm(.)
function.
I hope that helps!
Hi @BertvanderVeen, Thank you very much for the explanation! I used the function as suggested, but how can I link the values with the variables names. In my case, the final output of model$TMBfn$gr(model$TMBfn$par)
was a vector 1775 values. I have 260 dependent variables and samples grouped in four treatments.
The names of the parameters are stored in the $par
vector, so you can assign them to the gradient:
grad <- model$TMBfn$gr(model$TMBfn$par); names(grad) <- names(model$TMBfn$par)
Hi @BertvanderVeen , thanks again for the quick reply, but the names of the parameters are also not much informative to refer back to my dependent variables.
For my case I have repetition of the parameters (r0, b, lambda, lg_phi, u, and Au). I can see by the numbers that they will match with the combinations of treatments, variables and random effects. So, I could try to link them with the variable names, but I wonder if there is any other place where I can find this information already available.
You're interested in the b's. They are ordered per dependent variable and predictor, so for K
predictors you have p
vectors of length 1 + K
, where p
is the number of dependent variables in the response and the first value is for the intercept for that dependent variable.
Ok, I will check that. Thanks!