Closed damienneadle closed 5 years ago
1) Are you using the latest version of sjstats? If so, it simply wraps performance::r2()
, you could try that function (which should, however, yield the same error if all pkgs are up to date)
2) Do you have a reprex? Or at least your function call? Have you used a data
-argument?
Hi,
Yes, I am using the latest version - the same error is yielded.
Here is my model code:
mySimpleReducedGenPoisSocial1mModel= glmmTMB(socialData$Mean_number_in_1_constant~Age_rearing+Group+(1|Name), data = socialData, family=genpois)
Yes, I have used a data = argument. I noticed that I put in an unecessary call for the data twice - when I remove this I get the following:
r2(mySimpleReducedGenPoisSocial1mModel) [1] NA Warning messages: 1: Can't compute random effect variances. Some variance components equal zero. Solution: Respecify random structure! 2: In nlminb(start = par, objective = fn, gradient = gr, control = control$optCtrl) : NA/NaN function evaluation 3: mu of 1.9 is too close to zero, estimate of random effect variances may be unreliable.
Warning 2 is expected and Ben Bolker suggests this can be ignored. However, 1 and 3 seem off. Also, the value of NA is odd.
Thanks!
Ok. Warning 1 and 3 are expected, in particular if your model is a singular fit (you can use performance::check_singularity()
to check this).
If some variance components equal zero, there is no variance available that is needed to compute the r-squared, so the return value is NA
. However, we have revised the r2()
-function and it now returns a value, including a warning that random effects variances are not taken into account for r-squared.
You can install the performance pkg from GitHub (see details https://github.com/easystats/performance) and try r2()
from that package on your model. It should return a r-squared value, but that value is probably not reliable.
You also may need to update insight from GitHub first (https://github.com/easystats/insight), in order to make the GitHub version from performance work.
Right okay! Thanks for this. glmmTMB didn't warn me that this model was a singular fit so I had sort of assumed it wasn't.
I will consider my model further then! Thanks for the help!
My issue is that I am trying to run r2() on my glmmTMB genpois model. I have found that it comes up with an error message of:
The object it cannot find is clearly there and is properly specified. The warning message is also confusing - is this an issue with the function or something I am doing wrong? The updates to the package suggest that this should work.
Thanks!