We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
get_varcomp()
Base on this:
get_vc <- function(model) { model %>% VarCorr() %>% as_tibble() %>% setNames(c('group', 'effect', 'eff_2', 'var', 'sd')) %>% mutate( var_prop = var / sum(var), var_p = case_when( var_prop < 0.000001 ~ " 0%", TRUE ~ percent(var_prop, accuracy = 0.1, trim = FALSE) ), effect = gsub(effect, pattern = '[\\(,\\)]', replacement = ''), effect = ifelse(is.na(effect), '', effect) ) %>% select(group, var, var_p, sd, effect, everything()) }
The text was updated successfully, but these errors were encountered:
library(BioMathR) library(glmmTMB) library(lme4) library(lmerTest) m1 <- lmer(mpg ~ cyl + am + (1 | carb) + (1 | gear:carb), data = mtcars) VarCorr(m1) #> Groups Name Std.Dev. #> gear:carb (Intercept) 0.90804 #> carb (Intercept) 0.93346 #> Residual 2.82878 get_varcomp(m1) #> # A tibble: 3 × 7 #> group effect var var_p var_prop sd effect_2 #> <chr> <chr> <dbl> <chr> <dbl> <dbl> <chr> #> 1 gear:carb Intercept 0.825 " 8.5%" 0.085 0.908 <NA> #> 2 carb Intercept 0.871 " 9.0%" 0.09 0.933 <NA> #> 3 Residual <NA> 8.00 "82.5%" 0.825 2.83 <NA> m2 <- glmmTMB(mpg ~ cyl + am + (1 | carb) + (1 | gear:carb), REML = TRUE, data = mtcars) #> Warning in .local(x, logarithm, ...): the default value of argument 'sqrt' of #> method 'determinant(<CHMfactor>, <logical>)' may change from TRUE to FALSE as #> soon as the next release of Matrix; set 'sqrt' when programming VarCorr(m2) #> #> Conditional model: #> Groups Name Std.Dev. #> carb (Intercept) 0.93344 #> gear:carb (Intercept) 0.90806 #> Residual 2.82878 get_varcomp(m2) # ?!
Created on 2023-07-21 with reprex v2.0.2
Sorry, something went wrong.
SchmidtPaul
No branches or pull requests
Base on this:
The text was updated successfully, but these errors were encountered: