View source: R/multilevel.alpha.R
| multilevel.alpha | R Documentation |
This function computes point estimate and Monte Carlo confidence interval for
the multilevel coefficient alpha defined by Lai (2021) by calling the cfa
function in the R package lavaan. By default, the function prints level-specific
multilevel coefficient alpha with 95% Monte Carlo confidence interval based on
Huber-White standard errors.
multilevel.alpha(data, ..., cluster,
se = c("none", "standard", "robust.huber.white"),
optim.method = c("nlminb", "em"), missing = c("listwise", "fiml"),
nrep = 100000, seed = NULL, conf.level = 0.95,
print = c("all", "alpha", "item"), digits = 2, r.digits = 3,
as.na = NULL, write = NULL, append = TRUE, check = TRUE,
output = TRUE)
data |
a data frame. A saturated multilevel model is estimated to
obtain variances and covariances at the Within and Between
level. Note that the cluster variable specified in |
... |
an expression indicating the variable names in |
cluster |
either a character string indicating the variable name of
the cluster variable in |
se |
a character string indicating the standard errors used for
computing Monte Carlo confidence intervals, i.e., |
optim.method |
a character string indicating the optimizer, i.e., |
missing |
a character string indicating how to deal with missing data,
i.e., |
nrep |
an integer value indicating the number of Monte Carlo repetitions for computing confidence intervals. |
seed |
a numeric value specifying the seed of the random number generator for computing the Monte Carlo confidence interval. |
conf.level |
a numeric value between 0 and 1 indicating the confidence level of the interval. |
print |
a character vector indicating which results to show, i.e.
|
digits |
an integer value indicating the number of decimal places to be used for displaying mean, standard deviation, minimum, maximum, skewness, and kurtosis. |
r.digits |
an integer value indicating the number of decimal places to be used for displaying multilevel coefficient alpha, ICC(1), and standardized factor loadings. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
write |
a character string naming a file for writing the output into
either a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
In single-level data, coefficient \alpha (Cronbach, 1951) can be computed
as
\alpha = \frac{2p\Sigma_{k=2}^p\Sigma_{k^{\prime}=1}^{k-1}\sigma_{kk^{\prime}}}{(p - 1)\mathbf{1}^{\prime}\mathbf{\Sigma}\mathbf{1}}
assuming that the covariance matrix of p items is \Sigma with
elements \sigma_{ij^{\prime}}. Note that coefficients \alpha and \omega
represent the same population quantities under unidimensionality and essential
tau-equivalence. The multilevel extension of coefficient \alpha, however,
does not require estimation of parameters of a factor model. Conseuqntly, its
computation at the between-level remains the same regardless a composite is used
to measure a configural construct or a shared construct.
The reliability for an observed within-level
composite, Z^w_{ij}, is
\alpha^w = \frac{2p\Sigma_{k=2}^p\Sigma_{k^{\prime}=1}^{k-1}\sigma_{kk^{\prime}}^w}{(p - 1)\mathbf{1}^{\prime}\mathbf{\Sigma}^w\mathbf{1}}
The reliability for an observed between-level
composite, Z^b_{j}, is
\alpha^b = \frac{2p\Sigma_{k=2}^p\Sigma_{k^{\prime}=1}^{k-1}\sigma_{kk^{\prime}}^b}{(p - 1)[\mathbf{1}^{\prime}\mathbf{\Sigma}^b\mathbf{1} + \mathbf{1}^{\prime}\mathbf{\Sigma}^w\mathbf{1} / \tilde{n}]}
The reliability for an overall observed composite,
Z_{ij}, capturing the population variance of both the within-level and the
between-level components of the true score and the errors is
\alpha^{2l} = \frac{2p\Sigma_{k=2}^p\Sigma_{k^{\prime}=1}^{k-1}(\sigma_{kk^{\prime}}^w + \sigma_{kk^{\prime}}^b) }{(p - 1)[\mathbf{1}^{\prime}\mathbf{\Sigma}^b\mathbf{1} + \mathbf{1}^{\prime}\mathbf{\Sigma}^w\mathbf{1}]}
Note that \alpha^{2l} is simply the ratio of true variance to total variance
of the observed scores. In practice, \alpha^{2l} is not the most interesting
coefficient because researchers are mainly interested in distinguishing within-
and between effects (Castro-Alvarez et al., 2026).
Returns an object of class misty.object, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
data frame specified in |
args |
specification of function arguments |
model |
specified model |
model.fit |
fitted lavaan object ( |
check |
results of the convergence and model identification check |
result |
list with result tables, i.e., |
This function is based on the function multilevel_alpha from Mark Lai
(2021 supplementary codes) and uses the functions lavInspect, lavTech,
lavNames, parameterEstimates, and sem provided in the R
package lavaan by Yves Rosseel (2012). The internal function .internal.mvrnorm
is a copy of the mvrnorm function in the package MASS by Venables
and Ripley (2002).
Takuya Yanagida takuya.yanagida@univie.ac.at
Cronbach, L. J. (1951). Coefficient alpha and the internal structure of tests. Psychometrika, 16, 297-334. http://dx.doi.org/10.1007/BF02310555
Lai, M. H. C. (2021). Composite reliability of multilevel data: It’s about observed scores and construct meanings. Psychological Methods, 26(1), 90–102. https://doi.org/10.1037/met0000287
Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48, 1-36. https://doi.org/10.18637/jss.v048.i02
Venables, W. N., Ripley, B. D. (2002).Modern Applied Statistics with S (4th ed.). Springer. https://www.stats.ox.ac.uk/pub/MASS4/.
multilevel.omega, item.omega, multilevel.cfa,
multilevel.fit, multilevel.invar, multilevel.cor,
multilevel.descript, write.result
## Not run:
# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")
#————————————————————————————————————————————————————————————————————————————
# Cluster Variable Specification
# Example 1a: Specification using the argument '...'
multilevel.alpha(Demo.twolevel, y1:y4, cluster = "cluster")
# Example 1b: Alternative specification with cluster variable 'cluster' in 'data'
multilevel.alpha(Demo.twolevel[, c("y1", "y2", "y3", "y4", "cluster")], cluster = "cluster")
# Example 1c: Alternative specification with cluster variable 'cluster' not in 'data'
multilevel.alpha(Demo.twolevel[, c("y1", "y2", "y3", "y4")], cluster = Demo.twolevel$cluster)
#————————————————————————————————————————————————————————————————————————————
# Arguments 'se' and 'print'
# Example 4a: No confidence intervals to speed up computation
multilevel.alpha(Demo.twolevel, y1:y4, cluster = "cluster", se = "none")
# Example 4b: Alpha and item statistics
multilevel.alpha(Demo.twolevel, y1:y4, cluster = "cluster", print = "all")
#————————————————————————————————————————————————————————————————————————————
# Write Results
# Example 5a: Write results into a text file
multilevel.alpha(Demo.twolevel, y1, y2, y3, y4, cluster = "cluster",
write = "Multilevel_Alpha.txt")
# Example 5b: Write results into a Excel file
multilevel.alpha(Demo.twolevel, y1, y2, y3, y4, cluster = "cluster",
write = "Multilevel_Alpha.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.