View source: R/diary_functions.R
icc_11 | R Documentation |
icc_11
computes the intraclass correlation (ICC) based on a single
rater with a single dimension, aka ICC(1,1). Traditionally, this is the type
of ICC used for multilevel analysis where the value is interpreted as the
proportion of variance accounted for by group membership. In other words,
ICC(1,1) = the proportion of between-group variance; 1 - ICC(1,1) = the
proportion of within-group variance.
icc_11(x, grp, how = "lme", REML = TRUE)
x |
numeric vector. |
grp |
atomic vector the same length as |
how |
character vector of length 1 specifying how the ICC(1,1) should be
calculated. There are four options: 1) "lme" uses a linear mixed effects
model with the function |
REML |
logical vector of length 1 specifying whether restricted maximum likelihood estimation (TRUE) should be used rather than traditional maximum likelihood estimation (FALSE). Only used for linear mixed effects models if how = "lme" or how = "lmer". |
numeric vector of length 1 providing ICC(1,1) and computed based on
the how
argument.
iccs_11
# ICC(1,1) for multiple variables,
icc_all_by
# all six types of ICCs by group,
lme
# how = "lme" function,
lmer
# how = "lmer" function,
aov
# how = "aov" function,
# BALANCED DATA (how = "aov" and "lme"/"lmer" do YES provide the same value)
str(InsectSprays)
icc_11(x = InsectSprays$"count", grp = InsectSprays$"spray", how = "aov")
icc_11(x = InsectSprays$"count", grp = InsectSprays$"spray", how = "lme")
icc_11(x = InsectSprays$"count", grp = InsectSprays$"spray", how = "lmer")
icc_11(x = InsectSprays$"count", grp = InsectSprays$"spray",
how = "raw") # biased estimator and not recommended. Only available for teaching purposes.
# UN-BALANCED DATA (how = "aov" and "lme"/"lmer" do NOT provide the same value)
dat <- as.data.frame(lmeInfo::Bryant2016)
icc_11(x = dat$"outcome", grp = dat$"case", how = "aov")
icc_11(x = dat$"outcome", grp = dat$"case", how = "lme")
icc_11(x = dat$"outcome", grp = dat$"case", how = "lmer")
icc_11(x = dat$"outcome", grp = dat$"case", how = "lme", REML = FALSE)
icc_11(x = dat$"outcome", grp = dat$"case", how = "lmer", REML = FALSE)
# how = "lme" does not account for any correlation structure
lme_obj <- nlme::lme(outcome ~ 1, random = ~ 1 | case,
data = dat, na.action = na.exclude,
correlation = nlme::corAR1(form = ~ 1 | case), method = "REML")
var_corr <- nlme::VarCorr(lme_obj) # VarCorr.lme
vars <- as.double(var_corr[, "Variance"])
btw <- vars[1]
wth <- vars[2]
btw / (btw + wth)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.