icc_all_by {quest}R Documentation

All Six Intraclass Correlations by Group

Description

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).

Usage

icc_all_by(data, vrb.nm, grp.nm, ci.level = 0.95, check = TRUE)

Arguments

data

data.frame of data.

vrb.nm

character vector of colnames from data specifying the variables.

grp.nm

character vector of colnames from data specifying the groups.

ci.level

double vector of length 1 specifying the confidence level. It must range from 0 to 1.

check

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).

Details

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.

Value

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:

icc11_est

ICC(1,1) parameter estimate

icc11_lwr

ICC(1,1) lower bound of the confidence interval

icc11_upr

ICC(1,1) lower bound of the confidence interval

icc21_est

ICC(2,1) parameter estimate

icc21_lwr

ICC(2,1) lower bound of the confidence interval

icc21_upr

ICC(2,1) lower bound of the confidence interval

icc31_est

ICC(3,1) parameter estimate

icc31_lwr

ICC(3,1) lower bound of the confidence interval

icc31_upr

ICC(3,1) lower bound of the confidence interval

icc1k_est

ICC(1,k) parameter estimate

icc1k_lwr

ICC(1,k) lower bound of the confidence interval

icc1k_upr

ICC(1,k) lower bound of the confidence interval

icc2k_est

ICC(2,k) parameter estimate

icc2k_lwr

ICC(2,k) lower bound of the confidence interval

icc2k_upr

ICC(2,k) lower bound of the confidence interval

icc3k_est

ICC(3,k) parameter estimate

icc3k_lwr

ICC(3,k) lower bound of the confidence interval

icc3k_upr

ICC(3,k) lower bound of the confidence interval

lmer_nobs

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.

lmer_ngrps

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].

lmer_logLik

logLik of the linear mixed effects model

lmer_sing

binary variable where 1 = the linear mixed effects model had a singularity in the random effects covariance matrix or 0 = it did not

lmer_warn

binary variable where 1 = the linear mixed effects model returned a warning or 0 = it did not

lmer_err

binary variable where 1 = the linear mixed effects model returned an error or 0 = it did not

warn_mssg

character vector providing the warning messages for any warnings. If a group did not generate a warning, then the value is NA

err_mssg

character vector providing the error messages for any warnings. If a group did not generate an error, then the value is NA

References

Shrout, P.E., & Fleiss, J.L. (1979). Intraclass correlations: Uses in assessing rater reliability. Psychological Bulletin, 86(2), 420-428.

See Also

ICC lmer

Examples


# 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


[Package quest version 0.2.0 Index]