R2_glmm: An adjusted coefficient of determination (R2) for generalized...

View source: R/R2_glmm.R

R2_glmmR Documentation

An adjusted coefficient of determination (R2) for generalized linear mixed models

Description

This function produces adjusted R2 for generalized linear mixed models which was crafted following the guidance provided by Professor Hans-Peter Piepho.

Usage

  R2_glmm(model, over_disp=FALSE)

Arguments

model

An object returned by lmer, glmer or glmmTMB.

over_disp

A logical scalar to indicate whether model with over-dispersion or not. The default value is FALSE.

Value

Adjusted R2 in percentage for Total (fixed + random), Fiexd, Random and individual random term.

References

Piepho HP. An adjusted coefficient of determination (R2 ) for generalized linear mixed models in one go. Biom J. 2023 Oct;65(7):e2200290. doi: 10.1002/bimj.202200290. Epub 2023 May 1. PMID: 37127864.

Examples

  library(predictmeans)
  Oats$nitro <- factor(Oats$nitro)
  (fm <- lmer(yield ~ nitro*Variety+(1|Block/Variety), data=Oats))
  R2_glmm(fm)
  (gm <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
              data = cbpp, family = binomial))
  R2_glmm(gm)		  

predictmeans documentation built on May 29, 2024, 9:49 a.m.