[R-sig-ME] Calculating R2 for a GLMM with small response values/Tweedie family

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Sun Apr 16 15:31:36 CEST 2023


     Hmm.

   Based on the code it looks like something like

## mod is the original fitted model

mod.r <- update(mod, . ~ 1)

n <- nobs(mod)

(1 - exp(-2/n * (logLik(mod) - logLik(mod.r))))/(1 -
         exp(2/n * logLik(mod.r)))


   should do it?

On 2023-04-16 7:40 a.m., Anthony R. Ives via R-sig-mixed-models wrote:
> Skye,
>
> I�d use a partial R2. I know that people like marginal and conditional R2�s, but I don�t understand how they can be interpreted as �amount of variation explained by�� A partial R2 explicitly asks how much loss-of-fit occurs with removal of a component (fixed or random) of a model. A (the) main problem solved by mixed models is violation of the exogeneity assumption of OLS, and marginal/conditional R2�s are insensitive to this problem.
>
>
> You can calculate a partial R2 from likelihoods (from models fit with ML): see equation 17 in Ives, A.R. (2019. Rs for Correlated Data: Phylogenetic Models, LMMs, and GLMMs. Systematic Biology, 68, 234-251). You could grab the code from the package rr2, but I don�t think it can be used directly because it won�t recognize the class for glmmTMB. If you need a hand, just shoot me a private email.
>
>
>
> Cheers, Tony
>
>
> From: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> on behalf of Skye Bruce via R-sig-mixed-models <r-sig-mixed-models using r-project.org>
> Date: Saturday, April 15, 2023 at 4:13 PM
> To: r-sig-mixed-models using r-project.org <r-sig-mixed-models using r-project.org>
> Subject: Re: [R-sig-ME] Calculating R2 for a GLMM with small response values/Tweedie family
> Greetings,
>
> I am emailing to ask about calculating R2 for a GLMM using Tweedie family of distributions in the glmmTMB + performance packages in R. My response variable contains many zeroes and very small values, and performance is having trouble calculating my model's distribution-specific variance, making the resulting R2 unreliable. Is there a more reliable way to calculate R2 for this GLMM?
>
> I have measured my response variable, monarch butterfly eggs and larvae per m2, on grazed lands that vary in (predictors) grazing management category, floral richness, milkweed density (stems/m2) over two years, with three visits per year to each site.
>
> Data .csv file attached.
>
> Input:
> mod1.egglarv1m.twe <- glmmTMB(egglarva1m ~ category + florarich + submilk1m + visit + year + category:year + (1|site),
>                                data = egglarv1m.scale,
>                                family = tweedie)
> performance::r2(mod1.egglarv1m.twe)
>
> Output:
> # R2 for Mixed Models
>
>    Conditional R2: 1.000
>       Marginal R2: 0.724
> Warning messages:
> 1: mu of 0.0 is too close to zero, estimate of random effect variances may be unreliable.
> 2: Can't calculate model's distribution-specific variance. Results are not reliable.
>
> Thank you for your assistance,
>
> Skye Bruce
>
> PhD Student
> University of Wisconsin�Madison | Entomology
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> 	[[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list