Skip to content

Instantly share code, notes, and snippets.

@Rekyt
Last active February 23, 2016 14:26
Show Gist options
  • Select an option

  • Save Rekyt/d7d504dffbd7d05c443a to your computer and use it in GitHub Desktop.

Select an option

Save Rekyt/d7d504dffbd7d05c443a to your computer and use it in GitHub Desktop.
R squared for list of Mixed models
# Compute R squared from a list of computed and selected models
# Packages ---------------------------------------------------------------------------------------
library(MuMIn)
# Fit general model ------------------------------------------------------------------------------
global_mod = lm(mpg ~ ., data = mtcars)
# Model selection --------------------------------------------------------------------------------
dd = dredge(global_mod) # Summary table of all models
all_models = get.models(dd, subset = TRUE)
# R Squared --------------------------------------------------------------------------------------
rsq = do.call(rbind, lapply(all_models, r.squaredGLMM))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment