Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r2_nakagawa and glmmTMB with beta_family #710

Closed
POHedwall opened this issue Apr 11, 2024 · 4 comments
Closed

r2_nakagawa and glmmTMB with beta_family #710

POHedwall opened this issue Apr 11, 2024 · 4 comments

Comments

@POHedwall
Copy link

Hi everyone,
Last year I was working on some hurdle glmmTMB models with beta_family and produced pseudo-r2s from these models with r2_nakagawa. After a couple of months´ break, including a shift of computer (now Windows10) and installing latest versions of R and packages, I now get considerably different results from r2_nakagawa including a warning:

"r2_nakagawa(GLMM2.6)

R2 for Mixed Models

Conditional R2: 1.086
Marginal R2: 0.943
Warning message:
Model's distribution-specific variance is negative. Results are not reliable."

Last time I used the code the corresponding conditional and marginal R2s were 0.765 and 0.66 which seems more reasonable. No warning that time either.

Unfortunately I dont remember which version of R, glmmTMB and Performance I used previously but I wonder if any updates could have caused this difference, or if there are other known reasons? Attach code and data, please let me know if anything else is needed.

Grateful for any help on this matter!
Per-Ola Hedwall

mydata.csv
code_example.txt

@strengejacke
Copy link
Member

Yes, there have been changes both in glmmTMB in how the variance is calculated, and some revisions in insight::get_variance() (which is responsible for the R2 calculation for mixed models). This is probably not easy to resolve, but we're aware of these issues (see easystats/insight#664 or easystats/insight#764, to mention two examples).

@strengejacke
Copy link
Member

strengejacke commented May 20, 2024

See also easystats/insight#681 and easystats/insight#679

@strengejacke
Copy link
Member

strengejacke commented Jun 12, 2024

It should be fixed now. The current result is:

# R2 for Mixed Models

  Conditional R2: 1.000
     Marginal R2: 0.868

which is in line with MuMIn::r.squaredGLMM(). Package updates are not yet available, but will be soon.

@POHedwall
Copy link
Author

Great, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants