icc_all_by
computes each of the six intraclass correlations (ICC) in
Shrout & Fleiss (1979) by group. The ICCs differ by whether they treat
dimensions as fixed or random and whether they are for a single variable in
data[vrb.nm]
of the set of variables data[vrb.nm]
.
icc_all_by
also returns information about the linear mixed effects
modeling (using lmer
) used to compute the ICCs as well as
any warning or error messages by group. For an understanding of the six
different ICCs, see the following blogpost:
http://www.daviddisabato.com/blog/2021/10/1/the-six-different-types-of-intraclass-correlations-iccs.
icc_all_by
is a combination of by2
+
try_fun
+ ICC
(ICC
calls lmer
internally).
icc_all_by(data, vrb.nm, grp.nm, ci.level = 0.95, check = TRUE)
data.frame containing the unique combinations of the grouping variables
data[grp.nm]
and each group's intraclass correlations (ICCs), their confidence intervals,
information about the merMod
object from the linear mixed effects model,
and any warning or error messages from lmer
. For an understanding of the
six different ICCs, see the following blogpost:
http://www.daviddisabato.com/blog/2021/10/1/the-six-different-types-of-intraclass-correlations-iccs.
The first columns are always unique.data.frame(data[vrb.nm])
. All other columns are in the
following order with the following colnames:
ICC(1,1) parameter estimate
ICC(1,1) lower bound of the confidence interval
ICC(1,1) lower bound of the confidence interval
ICC(2,1) parameter estimate
ICC(2,1) lower bound of the confidence interval
ICC(2,1) lower bound of the confidence interval
ICC(3,1) parameter estimate
ICC(3,1) lower bound of the confidence interval
ICC(3,1) lower bound of the confidence interval
ICC(1,k) parameter estimate
ICC(1,k) lower bound of the confidence interval
ICC(1,k) lower bound of the confidence interval
ICC(2,k) parameter estimate
ICC(2,k) lower bound of the confidence interval
ICC(2,k) lower bound of the confidence interval
ICC(3,k) parameter estimate
ICC(3,k) lower bound of the confidence interval
ICC(3,k) lower bound of the confidence interval
number of observations used for the linear mixed effects model.
Note, this is the number of (non-missing) rows after data[vrb.nm]
has been stacked together via stack
.
number of groups used for the linear mixed effects model.
This is the number of unique combinations of the grouping variables after data[grp.nm]
.
logLik of the linear mixed effects model
binary variable where 1 = the linear mixed effects model had a singularity in the random effects covariance matrix or 0 = it did not
binary variable where 1 = the linear mixed effects model returned a warning or 0 = it did not
binary variable where 1 = the linear mixed effects model returned an error or 0 = it did not
character vector providing the warning messages for any warnings. If a group did not generate a warning, then the value is NA
character vector providing the error messages for any warnings. If a group did not generate an error, then the value is NA
data.frame of data.
character vector of colnames from data
specifying the
variables.
character vector of colnames from data
specifying the
groups.
double vector of length 1 specifying the confidence level. It must range from 0 to 1.
logical vector of length 1 specifying whether to check the
structure of the input arguments. For example, check whether
data[vrb.nm]
are all typeof numeric. This argument is available to
allow flexibility in whether the user values informative error messages
(TRUE) vs. computational efficiency (FALSE).
icc_all_by
internally suppresses any messages, warnings, or errors
returned by lmer
(e.g., "boundary (singular) fit: see
?isSingular") because that information is provided in the returned
data.frame.
Shrout, P.E., & Fleiss, J.L. (1979). Intraclass correlations: Uses in assessing rater reliability. Psychological Bulletin, 86(2), 420-428.
ICC
lmer
# one grouping variable
x <- icc_all_by(data = psych::bfi, vrb.nm = c("A2","A3","A4","A5"),
grp.nm = "gender")
# two grouping variables
y <- icc_all_by(data = psych::bfi, vrb.nm = c("A2","A3","A4","A5"),
grp.nm = c("gender","education"))
# with errors
z <- icc_all_by(data = psych::bfi, vrb.nm = c("A2","A3","A4","A5"),
grp.nm = c("age")) # NA for all ICC columns when there is an error
Run the code above in your browser using DataLab