item.invar | R Documentation |
This function is a wrapper function for evaluating configural, metric, scalar,
and strict between-group or longitudinal (partial) measurement invariance using
confirmatory factor analysis with continuous indicators by calling the cfa
function in the R package lavaan. By default, the function evaluates
configural, metric, and scalar measurement invariance by providing a table
with model fit information (i.e., chi-square test, fit indices based on a proper
null model, and information criteria) and model comparison (i.e., chi-square
difference test, change in fit indices, and change in information criteria).
Additionally, variance-covariance coverage of the data, descriptive statistics,
parameter estimates, modification indices, and residual correlation matrix can
be requested by specifying the argument print
.
item.invar(..., data = NULL, model = NULL, rescov = NULL, rescov.long = TRUE,
group = NULL, long = FALSE, cluster = NULL,
invar = c("config", "metric", "scalar", "strict"),
partial = NULL, ident = c("marker", "var", "effect"),
estimator = c("ML", "MLM", "MLMV", "MLMVS", "MLF", "MLR",
"GLS", "WLS", "DWLS", "WLSM", "WLSMV",
"ULS", "ULSM", "ULSMV", "DLS", "PML"),
missing = c("listwise", "pairwise", "fiml", "two.stage",
"robust.two.stage", "doubly.robust"), null.model = TRUE,
print = c("all", "summary", "coverage", "descript", "fit", "est",
"modind", "resid"),
print.fit = c("all", "standard", "scaled", "robust"),
mod.minval = 6.63, resid.minval = 0.1, digits = 3, p.digits = 3,
as.na = NULL, write = NULL, append = TRUE, check = TRUE, output = TRUE)
... |
a matrix or data frame. If |
data |
a data frame when specifying one or more variables in the
argument |
model |
a character vector specifying a measurement model with one
factor, or a list of character vectors for specifying a
measurement model with more than one factor for evaluating
between-group measurement invariance when |
rescov |
a character vector or a list of character vectors for specifying
residual covariances, e.g., |
rescov.long |
logical: if |
group |
either a character string indicating the variable name of
the grouping variable in the matrix or data frame specified
in |
long |
logical: if |
cluster |
either a character string indicating the variable name
of the cluster variable in |
invar |
a character string indicating the level of measurement
invariance to be evaluated, i.e., |
partial |
a character string or character vector containing the labels
of the parameters which should be free in all groups or across
time to specify a partial measurement invariance model. Note
that the labels of the parameters need to match the labels
shown in the output, i.e., |
ident |
a character string indicating the method used for identifying
and scaling latent variables, i.e., |
estimator |
a character string indicating the estimator to be used
(see 'Details' in the help page of the |
missing |
a character string indicating how to deal with missing data,
i.e., |
null.model |
logical: if |
print |
a character string or character vector indicating which results
to show on the console, i.e. |
print.fit |
a character string or character vector indicating which
version of the CFI, TLI, and RMSEA to show on the console
when using a robust estimation method involving a scaling
correction factor, i.e., |
mod.minval |
numeric value to filter modification indices and only show
modifications with a modification index value equal or higher
than this minimum value. By default, modification indices
equal or higher 6.63 are printed. Note that a modification
index value of 6.63 is equivalent to a significance level
of |
resid.minval |
numeric value indicating the minimum absolute residual correlation coefficients and standardized means to highlight in boldface. By default, absolute residual correlation coefficients and standardized means equal or higher 0.1 are highlighted. Note that highlighting can be disabled by setting the minimum value to 1. |
digits |
an integer value indicating the number of decimal places
to be used for displaying results. Note that information
criteria and chi-square test statistic are printed with
|
p.digits |
an integer value indicating the number of decimal places
to be used for displaying p-values, covariance coverage
(i.e., |
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 |
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
data frame including all variables used in the analysis, i.e., indicators for the factor, grouping variable and cluster variable |
args |
specification of function arguments |
model |
list with specified model for the configural, metric, scalar, and strict invariance model |
model.fit |
list with fitted lavaan object of the configural, metric, scalar, and strict invariance model |
check |
list with the results of the convergence and model identification check for the configural, metric, scalar, and strict invariance model |
result |
list with result tables, i.e., |
The function uses the functions cfa
, fitmeasures
,lavInspect
,
lavTech
, lavTestLRT
, lavTestScore
, modindices
,
parameterEstimates
, parTable
, and standardizedsolution
provided in the R package lavaan by Yves Rosseel (2012).
Takuya Yanagida takuya.yanagida@univie.ac.at
Brosseau-Liard, P. E., & Savalei, V. (2014) Adjusting incremental fit indices for nonnormality. Multivariate Behavioral Research, 49, 460-470. https://doi.org/10.1080/00273171.2014.933697
Li, L., & Bentler, P. M. (2006). Robust statistical tests for evaluating the hypothesis of close fit of misspecified mean and covariance structural models. UCLA Statistics Preprint #506. University of California.
Little, T. D. (2013). Longitudinal structural equation modeling. Guilford Press.
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
item.cfa
, multilevel.invar
, write.result
## Not run:
# Load data set "HolzingerSwineford1939" in the lavaan package
data("HolzingerSwineford1939", package = "lavaan")
#-------------------------------------------------------------------------------
# Between-Group Measurement Invariance Evaluation
#..................
# Measurement model with one factor
# Example 1a: Specification of the grouping variable in 'x'
item.invar(HolzingerSwineford1939[, c("x1", "x2", "x3", "x4", "sex")], group = "sex")
# Example 1b: Specification of the grouping variable in 'group'
item.invar(HolzingerSwineford1939[, c("x1", "x2", "x3", "x4")],
group = HolzingerSwineford1939$sex)
# Example 1c: Alternative specification using the 'data' argument
item.invar(x1:x4, data = HolzingerSwineford1939, group = "sex")
# Example 1d: Alternative specification using the argument 'model'
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"), group = "sex")
# Example 1e: Alternative specification using the 'data' and 'model' argument
item.invar(., data = HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"), group = "sex")
#..................
# Measurement model with two factors
item.invar(HolzingerSwineford1939,
model = list(c("x1", "x2", "x3", "x4"),
c("x5", "x6", "x7", "x8")), group = "sex")
#..................
# Configural, metric, scalar, and strict measurement invariance
# Example 2: Evaluate configural, metric, scalar, and strict measurement invariance
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", invar = "strict")
#..................
# Partial measurement invariance
# Example 3: Free second factor loading (L2) and third intercept (T3)
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", partial = c("L2", "T3"), print = c("fit", "est"))
#..................
# Residual covariances
# Example 4a: One residual covariance
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
rescov = c("x3", "x4"), group = "sex")
# Example 4b: Two residual covariances
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
rescov = list(c("x1", "x2"), c("x3", "x4")), group = "sex")
#..................
# Scaled test statistic and cluster-robust standard errors
# Example 5a: Specify cluster variable using a variable name in 'x'
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", cluster = "agemo")
# Example 5b: Specify vector of the cluster variable in the argument 'cluster'
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", cluster = HolzingerSwineford1939$agemo)
#..................
# Default Null model
# Example 6: Specify default null model for computing incremental fit indices
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", null.model = FALSE)
#..................
# Print argument
# Example 7a: Request all results
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", print = "all")
# Example 7b: Request fit indices with ad hoc non-normality correction
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", print.fit = "scaled")
# Example 7c: Request modification indices with value equal or higher than 10
# and highlight residual correlations equal or higher than 0.3
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", print = c("modind", "resid"),
mod.minval = 10, resid.minval = 0.3)
#..................
# Model syntax and lavaan summary of the estimated model
# Example 8
mod <- item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", output = FALSE)
# lavaan model syntax scalar invariance model
cat(mod$model$scalar)
# lavaan summary of the scalar invariance model
lavaan::summary(mod$model.fit$scalar, standardized = TRUE, fit.measures = TRUE)
#-------------------------------------------------------------------------------
# Longitudinal Measurement Invariance Evaluation
# Example 9: Two time points with three indicators at each time point
item.invar(HolzingerSwineford1939,
model = list(c("x1", "x2", "x3"),
c("x5", "x6", "x7")), long = TRUE)
#------------------------------------------------
# Write Results
# Example 10a: Write results into a text file
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", print = "all", write = "Invariance.txt", output = FALSE)
# Example 10b: Write results into an Excel file
item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", print = "all", write = "Invariance.xlsx", output = FALSE)
result <- item.invar(HolzingerSwineford1939, model = c("x1", "x2", "x3", "x4"),
group = "sex", print = "all", output = FALSE)
write.result(result, "Invariance.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.