performance icon indicating copy to clipboard operation
performance copied to clipboard

r2_nakagawa and glmmTMB with beta_family

Open POHedwall opened this issue 10 months ago • 2 comments

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

POHedwall avatar Apr 11 '24 08:04 POHedwall

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 https://github.com/easystats/insight/issues/664 or https://github.com/easystats/insight/issues/764, to mention two examples).

strengejacke avatar May 20 '24 08:05 strengejacke

See also https://github.com/easystats/insight/issues/681 and https://github.com/easystats/insight/issues/679

strengejacke avatar May 20 '24 08:05 strengejacke

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.

strengejacke avatar Jun 12 '24 16:06 strengejacke

Great, thanks a lot!

POHedwall avatar Jun 13 '24 05:06 POHedwall