Sem Tools
Sem Tools
1
2 R topics documented:
R topics documented:
auxiliary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
AVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
BootMiss-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
bsBootMiss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
calculate.D2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
chisqSmallN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
clipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
combinequark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
compareFit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
compRelSEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
dat2way . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
dat3way . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
datCat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
discriminantValidity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
EFA-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
[Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
efaUnrotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
exLong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
findRMSEApower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
findRMSEApowernested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
findRMSEAsamplesize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
findRMSEAsamplesizenested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
FitDiff-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
fmi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
htmt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
imposeStart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
indProd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
R topics documented: 3
kd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
kurtosis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
[Link]-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
lavaan2emmeans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
[Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
[Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
[Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
loadingFromAlpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
lrv2ord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
mardiaKurtosis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
mardiaSkew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
maximalRelia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
[Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
[Link]-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
miPowerFit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
[Link] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
monteCarloCI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
moreFitIndices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
mvrnonnorm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Net-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
nullRMSEA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
orthRotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
parcelAllocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
partialInvariance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
PAVranking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
permuteMeasEq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
permuteMeasEq-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
plausibleValues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
plotProbe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
plotRMSEAdist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
plotRMSEApower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
plotRMSEApowernested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
poolMAlloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
probe2WayMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
probe2WayRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
probe3WayMC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
probe3WayRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
quark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
residualCovariate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
runMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
semTools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
simParcel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
singleParamTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
skew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
splitSample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
SSpower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
tukeySEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
4 auxiliary
twostage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
twostage-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Index 189
Description
Automatically add auxiliary variables to a lavaan model when using full information maximum
likelihood (FIML) to handle missing data
Usage
auxiliary(model, data, aux, fun, ...)
Arguments
model The analysis model can be specified with 1 of 2 objects:
1. lavaan [Link] specifying a hypothesized model without mention of
auxiliary variables in aux
2. a parameter table, as returned by parTable, specifying the target model
without auxiliary variables. This option requires these columns (and silently
ignores all others): c("lhs","op","rhs","user","group","free","label","plabel","start"
data [Link] that includes auxiliary variables as well as any observed variables
in the model
aux character. Names of auxiliary variables to add to model
fun character. Name of a specific lavaan function used to fit model to data (i.e.,
"lavaan", "cfa", "sem", or "growth"). Only required for auxiliary.
... additional arguments to pass to lavaan.
Details
These functions are wrappers around the corresponding lavaan functions. You can use them the
same way you use lavaan, but you must pass your full [Link] to the data argument. Because
the saturated-correlates approaches (Enders, 2008) treates exogenous variables as random, fixed.x
must be set to FALSE. Because FIML requires continuous data (although nonnormality corrections
can still be requested), no variables in the model nor auxiliary variables specified in aux can be
declared as ordered.
auxiliary 5
Value
a fitted lavaan object. Additional information is stored as a list in the @external slot:
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Enders, C. K. (2008). A note on the use of missing auxiliary variables in full information maxi-
mum likelihood-based structural equation models. Structural Equation Modeling, 15(3), 434–448.
doi:10.1080/10705510802154307
Examples
dat1 <- lavaan::HolzingerSwineford1939
[Link](12345)
dat1$z <- rnorm(nrow(dat1))
dat1$x5 <- ifelse(dat1$z < quantile(dat1$z, .3), NA, dat1$x5)
dat1$x9 <- ifelse(dat1$z > quantile(dat1$z, .8), NA, dat1$x9)
Description
Calculate average variance extracted (AVE) per factor from ‘lavaan‘ object
Usage
AVE(object, [Link] = TRUE, [Link] = c("[Link]", "[Link]"),
[Link] = character(0), dropSingle = TRUE, [Link] = TRUE)
Arguments
object A lavaan or [Link] object, expected to contain only exogenous common
factors (i.e., a CFA model). Cross-loadings are not allowed and will result in NA
for any factor with indicator(s) that cross-load.
[Link] logical indicating whether to compute AVE using observed variances in the
denominator. Setting FALSE triggers using model-implied variances in the de-
nominator.
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
"improper solutions" such as Heywood cases. NPD solutions are not excluded
by default because they are likely to occur due to sampling error, especially in
small samples. However, gross model misspecification could also cause NPD
solutions, users can compare pooled results with and without this setting as a
sensitivity analysis to see whether some imputations warrant further investiga-
tion.
[Link] character vector naming any common factors modeled in object whose indi-
cators’ AVE is not of interest.
dropSingle logical indicating whether to exclude factors defined by a single indicator from
the returned results. If TRUE (default), single indicators will still be included in
the total column when [Link] = TRUE.
[Link] logical indicating whether to return reliability coefficients in a [Link]
(one row per group/level), which is possible when every model block includes
the same factors (after excluding those in [Link] and applying dropSingle).
Details
The average variance extracted (AVE) can be calculated by
AVE 7
10 diag (ΛΨΛ0 ) 1
AV E = ,
10 diag Σ̂ 1
Note that this formula is modified from Fornell & Larcker (1981) in the case that factor variances
are not 1. The proposed formula from Fornell & Larcker (1981) assumes that the factor variances
are 1. Note that AVE will not be provided for factors consisting of items with dual loadings. AVE is
the property of items but not the property of factors. AVE is calculated with polychoric correlations
when ordinal indicators are used.
Value
numeric vector of average variance extracted from indicators per factor. For models with mul-
tiple "blocks" (any combination of groups and levels), vectors may be returned as columns in a
[Link] with additional columns indicating the group/level (see [Link]= argument de-
scription for caveat).
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Fornell, C., & Larcker, D. F. (1981). Evaluating structural equation models with unobservable
variables and measurement errors. Journal of Marketing Research, 18(1), 39–50. doi:10.2307/
3151312
See Also
compRelSEM for composite reliability estimates
Examples
data(HolzingerSwineford1939)
HS9 <- HolzingerSwineford1939[ , c("x7","x8","x9")]
HSbinary <- [Link]( lapply(HS9, cut, 2, labels=FALSE) )
names(HSbinary) <- c("y7","y8","y9")
HS <- cbind(HolzingerSwineford1939, HSbinary)
## works for multigroup models and for multilevel models (and both)
data([Link])
## assign clusters to arbitrary groups
[Link]$g <- ifelse([Link]$cluster %% 2L, "type1", "type2")
model2 <- ' group: type1
level: within
fac =~ y1 + L2*y2 + L3*y3
level: between
fac =~ y1 + L2*y2 + L3*y3
group: type2
level: within
fac =~ y1 + L2*y2 + L3*y3
level: between
fac =~ y1 + L2*y2 + L3*y3
'
fit2 <- sem(model2, data = [Link], cluster = "cluster", group = "g")
AVE(fit2)
BootMiss-class Class For the Results of Bollen-Stine Bootstrap with Incomplete Data
Description
This class contains the results of Bollen-Stine bootstrap with missing data.
Usage
## S4 method for signature 'BootMiss'
show(object)
Arguments
object, x object of class BootMiss
... Additional arguments to pass to hist
alpha alpha level used to draw confidence limits
nd number of digits to display
printLegend logical. If TRUE (default), a legend will be printed with the histogram
legendArgs list of arguments passed to the legend function. The default argument is a list
placing the legend at the top-left of the figure.
bsBootMiss 9
Value
The hist method returns a list of length == 2, containing the arguments for the call to hist and
the arguments to the call for legend, respectively.
Slots
time A list containing 2 difftime objects (transform and fit), indicating the time elapsed for
data transformation and for fitting the model to bootstrap data sets, respectively.
transData Transformed data
bootDist The vector of chi2 values from bootstrap data sets fitted by the target model
origChi The chi2 value from the original data set
df The degree of freedom of the model
bootP The p value comparing the original chi2 with the bootstrap distribution
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
See Also
bsBootMiss
Examples
Description
Implement the Bollen and Stine’s (1992) Bootstrap when missing observations exist. The imple-
mented method is proposed by Savalei and Yuan (2009). This can be used in two ways. The first
and easiest option is to fit the model to incomplete data in lavaan using the FIML estimator, then
pass that lavaan object to bsBootMiss.
Usage
bsBootMiss(x, transformation = 2, nBoot = 500, model, rawData, Sigma, Mu,
group, ChiSquared, EMcov, writeTransData = FALSE, transDataOnly = FALSE,
writeBootData = FALSE, bootSamplesOnly = FALSE, writeArgs, seed = NULL,
suppressWarn = TRUE, showProgress = TRUE, ...)
10 bsBootMiss
Arguments
x A target lavaan object used in the Bollen-Stine bootstrap
transformation The transformation methods in Savalei and Yuan (2009). There are three meth-
ods in the article, but only the first two are currently implemented here. Use
transformation = 1 when there are few missing data patterns, each of which
has a large size, such as in a planned-missing-data design. Use transformation
= 2 when there are more missing data patterns. The currently unavailable transformation
= 3 would be used when several missing data patterns have n = 1.
nBoot The number of bootstrap samples.
model Optional. The target model if x is not provided.
rawData Optional. The target raw data set if x is not provided.
Sigma Optional. The model-implied covariance matrix if x is not provided.
Mu Optional. The model-implied mean vector if x is not provided.
group Optional character string specifying the name of the grouping variable in rawData
if x is not provided.
ChiSquared Optional. The model’s χ2 test statistic if x is not provided.
EMcov Optional, if x is not provided. The EM (or Two-Stage ML) estimated covariance
matrix used to speed up Transformation 2 algorithm.
writeTransData Logical. If TRUE, the transformed data set is written to a text file, transDataOnly
is set to TRUE, and the transformed data is returned invisibly.
transDataOnly Logical. If TRUE, the result will provide the transformed data only.
writeBootData Logical. If TRUE, the stacked bootstrap data sets are written to a text file, bootSamplesOnly
is set to TRUE, and the list of bootstrap data sets are returned invisibly.
bootSamplesOnly
Logical. If TRUE, the result will provide bootstrap data sets only.
writeArgs Optional list. If writeBootData = TRUE or writeBootData = TRUE, user can
pass arguments to the [Link] function as a list. Some default values are
provided: file = "[Link]", [Link] = FALSE, and na = "-
999", but the user can override all of these by providing other values for those
arguments in the writeArgs list.
seed The seed number used in randomly drawing bootstrap samples.
suppressWarn Logical. If TRUE, warnings from lavaan function will be suppressed when fitting
the model to each bootstrap sample.
showProgress Logical. Indicating whether to display a progress bar while fitting models to
bootstrap samples.
... The additional arguments in the lavaan function. See also lavOptions
Details
The second is designed for users of other software packages (e.g., LISREL, EQS, Amos, or Mplus).
Users can import their data, χ2 value, and model-implied moments from another package, and they
have the option of saving (or writing to a file) either the transformed data or bootstrapped samples
of that data, which can be analyzed in other programs. In order to analyze the bootstrapped samples
and return a p value, users of other programs must still specify their model using lavaan syntax.
bsBootMiss 11
Value
As a default, this function returns a BootMiss object containing the results of the bootstrap samples.
Use show, summary, or hist to examine the results. Optionally, the transformed data set is returned
if transDataOnly = TRUE. Optionally, the bootstrap data sets are returned if bootSamplesOnly =
TRUE.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Syntax for transformations borrowed from [Link]
References
Bollen, K. A., & Stine, R. A. (1992). Bootstrapping goodness-of-fit measures in structural equation
models. Sociological Methods & Research, 21(2), 205–229. doi:10.1177/0049124192021002004
Savalei, V., & Yuan, K.-H. (2009). On the model-based bootstrap with missing data: Obtaining
a p-value for a test of exact fit. Multivariate Behavioral Research, 44(6), 741–763. doi:10.1080/
00273170903333590
See Also
BootMiss
Examples
## Not run:
dat1 <- HolzingerSwineford1939
dat1$x5 <- ifelse(dat1$x1 <= quantile(dat1$x1, .3), NA, dat1$x5)
dat1$x9 <- ifelse([Link](dat1$x5), NA, dat1$x9)
temp
summary(temp)
hist(temp)
hist(temp, printLegend = FALSE) # suppress the legend
## user can specify alpha level (default: alpha = 0.05), and the number of
## digits to display (default: nd = 2). Pass other arguments to hist(...),
## or a list of arguments to legend() via "legendArgs"
12 calculate.D2
## End(Not run)
Description
This is a utility function used to calculate the "D2" statistic for pooling test statistics across multi-
ple imputations. This function is called by several functions used for [Link] objects, such as
[Link], [Link], and [Link]. But this function can be used for any
general scenario because it only requires a vector of χ2 statistics (one from each imputation) and the
degrees of freedom for the test statistic. See Li, Meng, Raghunathan, & Rubin (1991) and Enders
(2010, chapter 8) for details about how it is calculated.
Usage
Arguments
w numeric vector of Wald χ2 statistics. Can also be Wald z statistics, which will
be internally squared to make χ2 statistics with one df (must set DF = 0L).
DF degrees of freedom (df ) of the χ2 statistics. If DF = 0L (default), w is assumed to
contain z statistics, which will be internally squared.
asymptotic logical. If FALSE (default), the pooled test will be returned as an F-distributed
statistic with numerator (df1) and denominator (df2) degrees of freedom. If
TRUE, the pooled F statistic will be multiplied by its df1 on the assumption that
its df2 is sufficiently large enough that the statistic will be asymptotically χ2
distributed with df1.
Value
A numeric vector containing the test statistic, df, its p value, and 2 missing-data diagnostics: the
relative invrease in variance (RIV, or average for multiparameter tests: ARIV) and the fraction
missing information (FMI = ARIV / (1 + ARIV)).
Author(s)
References
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from
repeated p-values with multiply-imputed data. Statistica Sinica, 1(1), 65–92. Retrieved from
[Link]
See Also
[Link], [Link], [Link]
Examples
## generate a vector of chi-squared values, just for example
DF <- 3 # degrees of freedom
M <- 20 # number of imputations
CHI <- rchisq(M, DF)
Description
Calculate small-N corrections for chi2 model-fit test statistic to adjust for small sample size (relative
to model size).
Usage
chisqSmallN(fit0, fit1 = NULL, [Link] = if ([Link](fit1))
c("swain", "yuan.2015") else "yuan.2005", ..., [Link] = c("[Link]",
"[Link]"))
Arguments
fit0, fit1 lavaan object(s) provided after running the cfa, sem, growth, or lavaan func-
tions. [Link] object(s) also accepted.
14 chisqSmallN
[Link] character indicating the small-N correction method to use. Multiple may be
chosen (all of which assume normality), as described in Shi et al. (2018):
c("swain","yuan.2015","yuan.2005","bartlett"). Users may also sim-
ply select "all".
... Additional arguments to the lavTestLRT or [Link] functions. Ignored
when [Link](fit1).
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Ignored unless fit0 (and optionally fit1) is a [Link] object. See
[Link] for a description of options and defaults.
Details
Four finite-sample adjustments to the chi-squared statistic are currently available, all of which are
described in Shi et al. (2018). These all assume normally distributed data, and may not work well
with severely nonnormal data. Deng et al. (2018, section 4) review proposed small-N adjustments
that do not assume normality, which rarely show promise, so they are not implemented here. This
function currently will apply small-N adjustments to scaled test statistics with a warning that they
do not perform well (Deng et al., 2018).
Value
A list of numeric vectors: one for the originally requested statistic(s), along with one per re-
quested [Link]. All include the the (un)adjusted test statistic, its df, and the p value for the
test under the null hypothesis that the model fits perfectly (or that the 2 models have equivalent fit).
The adjusted chi-squared statistic(s) also include(s) the scaling factor for the small-N adjustment.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Deng, L., Yang, M., & Marcoulides, K. M. (2018). Structural equation modeling with many
variables: A systematic review of issues and developments. Frontiers in Psychology, 9, 580.
doi:10.3389/fpsyg.2018.00580
Shi, D., Lee, T., & Terry, R. A. (2018). Revisiting the model size effect in structural equation
modeling. Structural Equation Modeling, 25(1), 21–40. doi:10.1080/10705511.2017.1369088
Examples
clipboard Copy or save the result of lavaan or FitDiff objects into a clipboard
or a file
Description
Copy or save the result of lavaan or FitDiff object into a clipboard or a file. From the clipboard,
users may paste the result into the Microsoft Excel or spreadsheet application to create a table of
the output.
Usage
clipboard(object, what = "summary", ...)
Arguments
object The lavaan or FitDiff object
what The attributes of the lavaan object to be copied in the clipboard. "summary"
is to copy the screen provided from the summary function. "mifit" is to copy
the result from the miPowerFit function. Other attributes listed in the inspect
method in the lavaan-class could also be used, such as "coef", "se", "fit",
"samp", and so on. For the The FitDiff object, this argument is not active yet.
... Additional argument listed in the miPowerFit function (for lavaan object only).
file A file name used for saving the result
tableFormat If TRUE, save the result in the table format using tabs for seperation. Otherwise,
save the result as the output screen printed in the R console.
[Link] character vector specifying names of fit measures returned by fitMeasures
to be copied/saved. Only relevant if object is class FitDiff.
writeArgs list of additional arguments to be passed to [Link]
Value
The resulting output will be saved into a clipboard or a file. If using the clipboard function, users
may paste it in the other applications.
16 clipboard
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Examples
## Not run:
library(lavaan)
[Link] <- ' visual =~ x1 + c1*x2 + x3
textual =~ x4 + c1*x5 + x6
speed =~ x7 + x8 + x9 '
# Copy the modification indices and the model fit from the miPowerFit function
clipboard(fit, "mifit")
# Save the modification indices and the model fit from the miPowerFit function
saveFile(fit, "[Link]", "mifit")
## End(Not run)
combinequark 17
Description
This function builds upon the quark function to provide a final dataset comprised of the original
dataset provided to quark and enough principal components to be able to account for a certain level
of variance in the data.
Usage
combinequark(quark, percent)
Arguments
quark Provide the quark object that was returned. It should be a list of objects. Make
sure to include it in its entirety.
percent Provide a percentage of variance that you would like to have explained. That
many components (columns) will be extracted and kept with the output dataset.
Enter this variable as a number WITHOUT a percentage sign.
Value
The output of this function is the original dataset used in quark combined with enough principal
component scores to be able to account for the amount of variance that was requested.
Author(s)
Steven R. Chesnut (University of Southern Mississippi <[Link]@[Link]>)
See Also
quark
Examples
[Link](123321)
dat <- HolzingerSwineford1939[,7:15]
misspat <- matrix(runif(nrow(dat) * 9) < 0.3, nrow(dat))
dat[misspat] <- NA
dat <- cbind(HolzingerSwineford1939[,1:3], dat)
Description
This function will create the template to compare fit indices across multiple fitted lavaan objects.
The results can be exported to a clipboard or a file later.
Usage
compareFit(..., nested = TRUE, argsLRT = list(), indices = TRUE,
moreIndices = FALSE, [Link] = NULL, nPrior = 1)
Arguments
... fitted lavaan models or list(s) of lavaan objects. [Link] objects are also
accepted, but all models must belong to the same class.
nested logical indicating whether the models in ... are nested. See net for an em-
pirical test of nesting.
argsLRT list of arguments to pass to lavTestLRT, as well as to [Link] and
fitMeasures when comparing [Link] models.
indices logical indicating whether to return fit indices from the fitMeasures function.
Selecting particular indices is controlled in the summary method; see FitDiff.
moreIndices logical indicating whether to return fit indices from the moreFitIndices func-
tion. Selecting particular indices is controlled in the summary method; see
FitDiff.
[Link] optional fitted lavaan model passed to fitMeasures to calculate incremental
fit indices.
nPrior passed to moreFitIndices, if relevant
Value
A FitDiff object that saves model fit comparisons across multiple models. If the models are not
nested, only fit indices for each model are returned. If the models are nested, the differences in fit
indices are additionally returned, as well as test statistics comparing each sequential pair of models
(ordered by their degrees of freedom).
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
See Also
FitDiff, clipboard
compareFit 19
Examples
## non-nested models
fit1 <- cfa([Link], data = HolzingerSwineford1939)
m2 <- ' f1 =~ x1 + x2 + x3 + x4
f2 =~ x5 + x6 + x7 + x8 + x9 '
fit2 <- cfa(m2, data = HolzingerSwineford1939)
## Not run:
## also applies to [Link] objects (fit model to multiple imputations)
[Link](12345)
HSMiss <- HolzingerSwineford1939[ , paste("x", 1:9, sep = "")]
HSMiss$x5 <- ifelse(HSMiss$x1 <= quantile(HSMiss$x1, .3), NA, HSMiss$x5)
HSMiss$x9 <- ifelse([Link](HSMiss$x5), NA, HSMiss$x9)
HSMiss$school <- HolzingerSwineford1939$school
library(Amelia)
[Link] <- amelia(HSMiss, m = 20, noms = "school")
imps <- [Link]$imputations
## End(Not run)
Description
Calculate composite reliability from estimated factor-model parameters
Usage
compRelSEM(object, [Link] = TRUE, [Link] = FALSE, [Link] = TRUE,
config = character(0), shared = character(0), higher = character(0),
[Link] = FALSE, dropSingle = TRUE, [Link] = character(0),
[Link] = character(0), [Link] = c("[Link]", "[Link]"),
[Link] = TRUE)
Arguments
object A lavaan or [Link] object, expected to contain only exogenous common
factors (i.e., a CFA model).
[Link] logical indicating whether to compute AVE using observed variances in the
denominator. Setting FALSE triggers using model-implied variances in the de-
nominator.
[Link] logical indicating whether to assume (essential) tau-equivalence, yielding a
coefficient analogous to α. Setting FALSE yields an ω-type coefficient.
[Link] logical indicating whether to apply Green and Yang’s (2009, formula 21) cor-
rection, so that reliability is calculated for the actual ordinal response scale (ig-
nored for factors with continuous indicators). Setting FALSE yields coefficients
that are only applicable to the continuous latent-response scale.
config character vector naming any configural constructs in a multilevel CFA. For
these constructs (and optional total composite), Lai’s (2021) coefficients ω W
and ω 2L are returned (or corresponding α coefficients when [Link]=TRUE),
rather than Geldhof et al.’s (2014) coefficients for hypothetical composites of
latent components (although the same formula is used for ω W in either case).
compRelSEM 21
Note that the same name must be used for the factor component represented at
each level of the model.
shared character vector naming any shared constructs in a multilevel CFA. For these
constructs (and optional total composite), Lai’s (2021) coefficient ω B or αB is
returned, rather than Geldhof et al.’s (2014) between-level coefficient for hy-
pothetical composites of latent cluster means. Lai’s (2021) coefficient quan-
tifies reliability relative to error associated with both indicators (measurement
error) and subjects (sampling error), like a generalizability coefficient. Given
that subjects can be considered as raters of their cluster’s shared construct, an
interrater reliability (IRR) coefficient is also returned, quantifying reliability
relative to rater/sampling error alone. To quantify reliability relative to indi-
cator/measurement error alone (i.e., ω 2L ), the shared= construct name(s) can
additionally be included in config= argument.
higher character vector naming any higher-order constructs in object for which com-
posite reliability should be calculated. Ignored when [Link]=TRUE because
alpha is not based on a CFA model; instead, users must fit a CFA with tau-
equivalence constraints. To obtain Lai’s (2021) multilevel composite-reliability
indices for a higher-order factor, do not use this argument; instead, specify the
higher-order factor(s) using the shared= or config= argument (compRelSEM
will automatically check whether it includes latent indicators and apply the ap-
propriate formula).
[Link] logical indicating whether to return a final column containing the reliability
of a composite of all indicators (not listed in [Link]) of first-order
factors not listed in [Link]. Ignored in 1-factor models, and should
only be set TRUE if all factors represent scale dimensions that could be mean-
ingfully collapsed to a single composite (scale sum or scale mean). Setting
a negative value (e.g., -1 returns only the total-composite reliability (exclud-
ing coefficients per factor), except when requesting Lai’s (2021) coefficients for
multilevel configural or shared= constructs.
dropSingle logical indicating whether to exclude factors defined by a single indicator from
the returned results. If TRUE (default), single indicators will still be included in
the total column when [Link] = TRUE.
[Link] character vector naming any common factors modeled in object whose com-
posite reliability is not of interest. For example, higher-order or method factors.
Note that reliabilityL2() should be used to calculate composite reliability of
a higher-order factor.
[Link]
character vector naming any observed variables that should be ignored when
calculating composite reliability. This can be useful, for example, to estimate
reliability when an indicator is removed.
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
22 compRelSEM
"improper solutions" such as Heywood cases. NPD solutions are not excluded
by default because they are likely to occur due to sampling error, especially in
small samples. However, gross model misspecification could also cause NPD
solutions, users can compare pooled results with and without this setting as a
sensitivity analysis to see whether some imputations warrant further investiga-
tion.
[Link] logical indicating whether to return reliability coefficients in a [Link]
(one row per group/level), which is possible when every model block includes
the same factors (after excluding those in [Link] and applying dropSingle).
Details
Several coefficients for factor-analysis reliability have been termed "omega", which Cho (2021)
argues is a misleading misnomer and argues for using ρ to represent them all, differentiated by
descriptive subscripts. In our package, we number ω based on commonly applied calculations.
Bentler (1968) first introduced factor-analysis reliability for a unidimensional factor model with
congeneric indicators, labeling the coeficients α. McDonald (1999) later referred to this and other
reliability coefficients, first as θ (in 1970), then as ω, which is a source of confusion when reporting
coefficients (Cho, 2021). Coefficients based on factor models were later generalized to account for
multidimenisionality (possibly with cross-loadings) and correlated errors. The general ω formula
implemented in this function is:
P 2
k
i=1 λi V ar (ψ)
ω= ,
10 Σ̂1
where Σ̂ can be the model-implied covariance matrix from either the saturated model (i.e., the
"observed" covariance matrix, used by default) or from the hypothesized CFA model, controlled by
the [Link] argument. A k-dimensional vector 1 is used to sum elements in the matrix. Note that
if the model includes any directed effects (latent regression slopes), all coefficients are calculated
from total factor variances: lavInspect(object, "[Link]").
Assuming (essential) tau-equivalence ([Link]=TRUE) makes ω equivalent to coefficient α from clas-
sical test theory (Cronbach, 1951):
" Pk #
k i=1 σii
α= 1 − Pk ,
k−1
P
i=1 σii + 2 i<j σij
where k is the number of items in a factor’s composite, σii signifies item i’s variance, and σij
signifies the covariance between items i and j. Again, the [Link] argument controls whether α is
calculated using the observed or model-implied covariance matrix.
By setting [Link]=TRUE, one can estimate reliability for a single composite calculated using
all indicators in a multidimensional CFA (Bentler, 1972, 2009). Setting [Link] = -1 will
return only the total-composite reliability (not per factor).
Higher-Order Factors: The reliability of a composite that represents a higher-order construct
requires partitioning the model-implied factor covariance matrix Φ in order to isolate the common-
factor variance associated only with the higher-order factor. Using a second-order factor model, the
model-implied covariance matrix of observed indicators Σ̂ can be partitioned into 3 sources:
compRelSEM 23
10 ΛBΦB 0 Λ0 1
ωL1 = ,
10 Σ̂1
where 1 is the k-dimensional vector of 1s and k is the number of observed indicators in the com-
posite. Note that a higher-order factor can also have observed indicators.
Categorical Indicators: When all indicators (per composite) are ordinal, the [Link] argu-
ment controls whether the coefficient is calculated on the latent-response scale (FALSE) or on the
observed ordinal scale (TRUE, the default). For ω-type coefficients ([Link]=FALSE), Green and
Yang’s (2009, formula 21) approach is used to transform factor-model results back to the ordinal
response scale. When [Link]=TRUE, coefficient α is calculated using the covariance matrix
calculated from the integer-valued numeric weights for ordinal categories, consistent with its defi-
nition (Chalmers, 2018) and the alpha function in the psych package; this implies [Link]=TRUE,
so [Link]=FALSE will be ignored. When [Link]=FALSE, the standard α formula is applied to
the polychoric correlation matrix ("ordinal α"; Zumbo et al., 2007), estimated from the saturated or
hypothesized model (see [Link]), and ω is calculated from CFA results without applying Green
and Yang’s (2009) correction (see Zumbo & Kroc’s, 2019, for a rationalization). No method has
been proposed for calculating reliability with a mixture of categorical and continuous indicators,
so an error is returned if object includes factors with a mixture of indicator types (unless omitted
using [Link]). If categorical indicators load on a different factor(s) than continuous indica-
tors, then reliability will still be calculated separately for those factors, but [Link] must be
FALSE (unless [Link] is used to isolate factors with indicators of the same type).
Multilevel Measurement Models: Under the default settings, compRelSEM() will apply the same
formula in each "block" (group and/or level of analysis). In the case of multilevel SEMs, this
yields "reliability" for latent within- and between-level components, as proposed by Geldhof et al.
(2014). This is not recommended because the coefficients do not correspond to actual composites
that would be calculated from the observed data. Lai (2021) proposed coefficients for reliability
of actual composites, depending on the type of construct, which requires specifying the names of
constructs for which reliability is desired (or multiple constructs whose indicators would compose
a multidimensional composite). Configural (config=) and/or shared= constructs can be specified;
the same construct can be specified in both arguments, so that overall scale-reliability can be esti-
mated for a shared construct by including it in config. Instead of organizing the output by block
(the default), specifying config= and/or shared= will prompt organizing the output by $config
and/or $shared.
• The overall (_2L) scale reliability for configural constructs is returned, along with the relia-
bility of a purely individual-level composite (_W, calculated by cluster-mean centering).
24 compRelSEM
• The reliability for a shared construct quantifies generalizability across both indicators and
raters (i.e., subjects rating their cluster’s construct). Lüdtke et al. (2011) refer to these
as measurement error and sampling error, respectively. An interrater reliability (IRR) co-
efficient is also returned, quantifying generalizability across rater/sampling-error only. To
obtain a scale-reliability coefficient (quantifying a shared construct’s generalizability across
indicator/measurement-error only), include the same factor name in config=. Jak et al. (2021)
recommended modeling components of the same construct at both levels, but users may also
saturate the within-level model (Lai, 2021).
Be careful about including Level-2 variables in the model, especially whether it makes sense to in-
clude them in a total composite for a Level-2 construct. dropSingle=TRUE only prevents estimating
reliability for a single-indicator construct, not from including such an indicator in a total composite.
It is permissible for shared= constructs to have indicators at Level-2 only. If it is necessary to model
other Level-2 variables (e.g., to justify the missing-at-random assumption when using missing =
"FIML" estimation), they should be placed in the [Link]= argument to exclude them
from total composites.
Value
A numeric vector of composite reliability coefficients per factor, or a list of vectors per "block"
(group and/or level of analysis), optionally returned as a [Link] when possible (see [Link]=
argument description for caveat). If there are multiple factors, whose multidimensional indicators
combine into a single composite, users can request [Link]=TRUE to add a column includ-
ing a reliability coefficient for the total composite, or [Link] = -1 to return only the total-
composite reliability (ignored when config= or shared= is specified because each factor’s specifi-
cation must be checked across levels).
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Uses hidden functions written by Sunthud Pornprasertmanit (<psunthud@[Link]>) for the old
reliability() function.
References
Bentler, P. M. (1968). Alpha-maximized factor analysis (alphamax): Its relation to alpha and canon-
ical factor analysis. Psychometrika, 33(3), 335–345. doi:10.1007/BF02289328
Bentler, P. M. (1972). A lower-bound method for the dimension-free measurement of internal
consistency. Social Science Research, 1(4), 343–357. doi:10.1016/0049089X(72)900828
Bentler, P. M. (2009). Alpha, dimension-free, and model-based internal consistency reliability.
Psychometrika, 74(1), 137–143. doi:10.1007/s1133600891001
Chalmers, R. P. (2018). On misconceptions and the limited usefulness of ordinal alpha. Educational
and Psychological Measurement, 78(6), 1056–1071. doi:10.1177/0013164417727036
Cho, E. (2021) Neither Cronbach’s alpha nor McDonald’s omega: A commentary on Sijtsma and
Pfadt. Psychometrika, 86(4), 877–886. doi:10.1007/s11336021098011
Cronbach, L. J. (1951). Coefficient alpha and the internal structure of tests. Psychometrika, 16(3),
297–334. doi:10.1007/BF02310555
compRelSEM 25
Geldhof, G. J., Preacher, K. J., & Zyphur, M. J. (2014). Reliability estimation in a multilevel con-
firmatory factor analysis framework. Psychological Methods, 19(1), 72–91. doi:10.1037/a0032138
Green, S. B., & Yang, Y. (2009). Reliability of summed item scores using structural equation mod-
eling: An alternative to coefficient alpha. Psychometrika, 74(1), 155–167. doi:10.1007/s11336008-
90993
Jak, S., Jorgensen, T. D., & Rosseel, Y. (2021). Evaluating cluster-level factor models with lavaan
and Mplus. Psych, 3(2), 134–152. doi:10.3390/psych3020012
Lai, M. H. C. (2021). Composite reliability of multilevel data: It’s about observed scores and
construct meanings. Psychological Methods, 26(1), 90–102. doi:10.1037/met0000287
Lüdtke, O., Marsh, H. W., Robitzsch, A., & Trautwein, U. (2011). A 2 × 2 taxonomy of multi-
level latent contextual models: Accuracy–bias trade-offs in full and partial error correction models.
Psychological Methods, 16(4), 444–467. doi:10.1037/a0024376
McDonald, R. P. (1999). Test theory: A unified treatment. Mahwah, NJ: Erlbaum.
Zumbo, B. D., Gadermann, A. M., & Zeisser, C. (2007). Ordinal versions of coefficients alpha
and theta for Likert rating scales. Journal of Modern Applied Statistical Methods, 6(1), 21–29.
doi:10.22237/jmasm/1177992180
Zumbo, B. D., & Kroc, E. (2019). A measurement is a choice and Stevens’ scales of measurement
do not help make it: A response to Chalmers. Educational and Psychological Measurement, 79(6),
1184–1197. doi:10.1177/0013164419844305
See Also
maximalRelia for the maximal reliability of weighted composite
Examples
data(HolzingerSwineford1939)
HS9 <- HolzingerSwineford1939[ , c("x7","x8","x9")]
HSbinary <- [Link]( lapply(HS9, cut, 2, labels=FALSE) )
names(HSbinary) <- c("y7","y8","y9")
HS <- cbind(HolzingerSwineford1939, HSbinary)
## works for multigroup models and for multilevel models (and both)
data([Link])
## assign clusters to arbitrary groups
[Link]$g <- ifelse([Link]$cluster %% 2L, "type1", "type2")
model2 <- ' group: type1
level: 1
f1 =~ y1 + L2*y2 + L3*y3
f2 =~ y4 + L5*y5 + L6*y6
level: 2
f1 =~ y1 + L2*y2 + L3*y3
f2 =~ y4 + L5*y5 + L6*y6
group: type2
level: 1
f1 =~ y1 + L2*y2 + L3*y3
f2 =~ y4 + L5*y5 + L6*y6
level: 2
f1 =~ y1 + L2*y2 + L3*y3
f2 =~ y4 + L5*y5 + L6*y6
'
fit2 <- sem(model2, data = [Link], cluster = "cluster", group = "g")
compRelSEM(fit2) # Geldhof's indices (hypothetical, for latent components)
y5 ~~ y5 + y6
y6 ~~ y6
level: 2
f1 =~ y1 + L2*y2 + L3*y3
f2 =~ y4 + L5*y5 + L6*y6
'
fit.sat1 <- sem(mod.sat1, data = [Link], cluster = "cluster")
compRelSEM(fit.sat1, shared = c("f1","f2"))
Description
A simulated data set with 2 independent factors and 1 dependent factor where each factor has three
indicators
Usage
dat2way
Format
A [Link] with 500 observations of 9 variables.
x1 The first indicator of the first independent factor
x2 The second indicator of the first independent factor
x3 The third indicator of the first independent factor
x4 The first indicator of the second independent factor
x5 The second indicator of the second independent factor
x6 The third indicator of the second independent factor
28 dat3way
Source
Data were generated by the mvrnorm function in the MASS package.
Examples
head(dat2way)
Description
A simulated data set with 3 independent factors and 1 dependent factor where each factor has three
indicators
Usage
dat3way
Format
A [Link] with 500 observations of 12 variables.
x1 The first indicator of the first independent factor
x2 The second indicator of the first independent factor
x3 The third indicator of the first independent factor
x4 The first indicator of the second independent factor
x5 The second indicator of the second independent factor
x6 The third indicator of the second independent factor
x7 The first indicator of the third independent factor
x8 The second indicator of the third independent factor
x9 The third indicator of the third independent factor
x10 The first indicator of the dependent factor
x11 The second indicator of the dependent factor
x12 The third indicator of the dependent factor
Source
Data were generated by the mvrnorm function in the MASS package.
Examples
head(dat3way)
datCat 29
Description
A simulated data set with 2 factors with 4 indicators each separated into two groups
Usage
datCat
Format
g Sex of respondents
u1 Indicator 1
u2 Indicator 2
u3 Indicator 3
u4 Indicator 4
u5 Indicator 5
u6 Indicator 6
u7 Indicator 7
u8 Indicator 8
Source
Examples
head(datCat)
30 discriminantValidity
Description
Calculate discriminant validity statistics based on a fitted lavaan object
Usage
discriminantValidity(object, cutoff = 0.9, merge = FALSE, level = 0.95)
Arguments
object The lavaan model object returned by the cfa function.
cutoff A cutoff to be used in the constrained models in likelihood ratio tests.
merge Whether the constrained models should be constructed by merging two factors
as one. Implies cutoff = 1.
level The confidence level required.
Details
Evaluated on the measurement scale level, discriminant validity is commonly evaluated by checking
if each pair of latent correlations is sufficiently below one (in absolute value) that the latent variables
can be thought of representing two distinct constructs.
discriminantValidity function calculates two sets of statistics that are commonly used in dis-
criminant validity evaluation. The first set are factor correlation estimates and their confidence
intervals. The second set is a series of nested model tests, where the baseline model is compared
against a set of constrained models that are constructed by constraining each factor correlation to
the specified cutoff one at a time.
The function assume that the object is set of confirmatory factor analysis results where the latent
variables are scaled by fixing their variances to 1s. If the model is not a CFA model, the function will
calculate the statistics for the correlations among exogenous latent variables, but for the residual
variances with endogenous variables. If the latent variables are scaled in some other way (e.g.
fixing the first loadings), the function issues a warning and re-estimates the model by fixing latent
variances to 1 (and estimating all loadings) so that factor covariances are already estimated as
correlations.
The likelihood ratio tests are done by comparing the original baseline model against more con-
strained alternatives. By default, these alternatives are constructed by fixing each correlation at a
time to a cutoff value. The typical purpose of this test is to demonstrate that the estimated factor
correlation is well below the cutoff and a significant chi2 statistic thus indicates support for dis-
criminant validity. In some cases, the original correlation estimate may already be greater than the
cutoff, making it redundant to fit a "restricted" model. When this happens, the likelihood ratio test
will be replaced by comparing the baseline model against itself. For correlations that are estimated
to be negative, a negation of the cutoff is used in the constrained model.
EFA-class 31
Another alternative is to do a nested model comparison against a model where two factors are
merged as one by setting the merge argument to TRUE. In this comparison, the constrained model is
constructed by removing one of the correlated factors from the model and assigning its indicators
to the factor that remains in the model.
Value
A [Link] of latent variable correlation estimates, their confidence intervals, and a likelihood
ratio tests against constrained models. with the following attributes:
baseline The baseline model after possible rescaling.
constrained A list of the fitted constrained models used in the likelihood ratio test.
Author(s)
Mikko Rönkkö (University of Jyväskylä; <[Link]@[Link]>):
References
Rönkkö, M., & Cho, E. (2020). An updated guideline for assessing discriminant validity. Organi-
zational Research Methods. doi:10.1177/1094428120968614
Examples
library(lavaan)
Description
This class contains the results of rotated exploratory factor analysis
Usage
## S4 method for signature 'EFA'
show(object)
Arguments
Slots
Author(s)
See Also
Examples
# Rotated by Quartimin
rotated <- oblqRotate(unrotated, method = "quartimin")
summary(rotated)
[Link] 33
Description
Identify the number of factors to extract based on the Empirical Kaiser Criterion (EKC). The anal-
ysis can be run on a [Link] or data matrix (data), or on a correlation or covariance matrix
([Link]) and the sample size ([Link]). A [Link] is returned with two columns:
the eigenvalues from your data or covariance matrix and the reference eigenvalues. The number of
factors suggested by the Empirical Kaiser Criterion (i.e. the sample eigenvalues greater than the
reference eigenvalues), and the number of factors suggested by the original Kaiser Criterion (i.e.
sample eigenvalues > 1) is printed above the output.
Usage
[Link](data = NULL, [Link] = NULL, [Link] = NULL,
missing = "default", ordered = NULL, plot = TRUE)
Arguments
data A [Link] or data matrix containing columns of variables to be factor-
analyzed.
[Link] A covariance or correlation matrix can be used, instead of data, to estimate the
eigenvalues.
[Link] Number of observations (i.e. sample size) if [Link](data) and [Link]
is used.
missing If "listwise", cases with missing values are removed listwise from the data frame.
If "direct" or "ml" or "fiml" and the estimator is maximum likelihood, an EM al-
gorithm is used to estimate the unrestricted covariance matrix (and mean vector).
If "pairwise", pairwise deletion is used. If "default", the value is set depending
on the estimator and the mimic option (see details in lavCor).
ordered Character vector. Only used if object is a [Link]. Treat these variables
as ordered (ordinal) variables. Importantly, all other variables will be treated as
numeric (unless [Link] == TRUE in data). (see also lavCor)
plot logical. Whether to print a scree plot comparing the sample eigenvalues with
the reference eigenvalues.
Value
A [Link] showing the sample and reference eigenvalues.
The number of factors suggested by the Empirical Kaiser Criterion (i.e. the sample eigenvalues
greater than the reference eigenvalues) is returned as an attribute (see Examples).
The number of factors suggested by the original Kaiser Criterion (i.e. sample eigenvalues > 1) is
also printed as a header to the [Link]
34 efaUnrotate
Author(s)
Ylenio Longo (University of Nottingham; <yleniolongo@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Braeken, J., & van Assen, M. A. L. M. (2017). An empirical Kaiser criterion. Psychological
Methods, 22(3), 450–466. doi:10.1037/met0000074
Examples
## If you do not have raw data, you can use summary statistics
(x1 <- [Link]([Link] = myCovMat, [Link] = N, plot = FALSE))
(x2 <- [Link]([Link] = myCorMat, [Link] = N, plot = FALSE))
Description
This function will analyze unrotated exploratory factor analysis model. The unrotated solution can
be rotated by the orthRotate and oblqRotate functions.
Usage
efaUnrotate(data = NULL, nf, varList = NULL, start = TRUE, aux = NULL, ...)
efaUnrotate 35
Arguments
data A target [Link]
nf The desired number of factors
varList Target observed variables. If not specified, all variables in data will be used (or
[Link] if [Link](data); see cfa for argument descriptions).
start Use starting values in the analysis from the factanal function. If FALSE, the
starting values from the lavaan package will be used. TRUE is ignored with a
warning if the aux argument is used.
aux The list of auxiliary variables. These variables will be included in the model by
the saturated-correlates approach to account for missing information.
... Other arguments in the cfa function in the lavaan package, such as ordered,
se, estimator, or [Link] and [Link].
Details
This function will generate a lavaan script for unrotated exploratory factor analysis model such that
(1) all factor loadings are estimated, (2) factor variances are fixed to 1, (3) factor covariances are
fixed to 0, and (4) the dot products of any pairs of columns in the factor loading matrix are fixed to
zero (Johnson & Wichern, 2002). The reason for creating this function to supplement the factanal
function is that users can enjoy some advanced features from the lavaan package, such as scaled χ2 ,
diagonally weighted least squares estimation for ordinal indicators, or full-information maximum
likelihood (FIML) to handle incomplete data.
Value
A lavaan output of unrotated exploratory factor analysis solution.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Examples
Description
Usage
exLong
Format
Source
Examples
head(exLong)
findRMSEApower 37
Description
Find the proportion of the samples from the sampling distribution of RMSEA in the alternative
hypothesis rejected by the cutoff dervied from the sampling distribution of RMSEA in the null hy-
pothesis. This function can be applied for both test of close fit and test of not-close fit (MacCallum,
Browne, & Suguwara, 1996)
Usage
findRMSEApower(rmsea0, rmseaA, df, n, alpha = 0.05, group = 1)
Arguments
rmsea0 Null RMSEA
rmseaA Alternative RMSEA
df Model degrees of freedom
n Sample size of a dataset
alpha Alpha level used in power calculations
group The number of group that is used to calculate RMSEA.
Details
This function find the proportion of sampling distribution derived from the alternative RMSEA that
is in the critical region derived from the sampling distribution of the null RMSEA. If rmseaA is
greater than rmsea0, the test of close fit is used and the critical region is in the right hand side of the
null sampling distribution. On the other hand, if rmseaA is less than rmsea0, the test of not-close fit
is used and the critical region is in the left hand side of the null sampling distribution (MacCallum,
Browne, & Suguwara, 1996).
There is also a Shiny app called "power4SEM" that provides a graphical user interface for this func-
tionality (Jak et al., in press). It can be accessed at [Link]
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
MacCallum, R. C., Browne, M. W., & Sugawara, H. M. (1996). Power analysis and determi-
nation of sample size for covariance structure modeling. Psychological Methods, 1(2), 130–149.
doi:10.1037/1082989X.1.2.130
Jak, S., Jorgensen, T. D., Verdam, M. G., Oort, F. J., & Elffers, L. (2021). Analytical power cal-
culations for structural equation modeling: A tutorial and Shiny app. Behavior Research Methods,
53, 1385–1406. doi:10.3758/s13428020014790
38 findRMSEApowernested
See Also
• plotRMSEApower to plot the statistical power based on population RMSEA given the sample
size
• plotRMSEAdist to visualize the RMSEA distributions
• findRMSEAsamplesize to find the minium sample size for a given statistical power based on
population RMSEA
Examples
Description
Find the sample size that the power in rejection the samples from the alternative pair of RMSEA is
just over the specified power.
Usage
findRMSEApowernested(rmsea0A = NULL, rmsea0B = NULL, rmsea1A,
rmsea1B = NULL, dfA, dfB, n, alpha = 0.05, group = 1)
Arguments
rmsea0A The H0 baseline RMSEA
rmsea0B The H0 alternative RMSEA (trivial misfit)
rmsea1A The H1 baseline RMSEA
rmsea1B The H1 alternative RMSEA (target misfit to be rejected)
dfA degree of freedom of the more-restricted model
dfB degree of freedom of the less-restricted model
n Sample size
alpha The alpha level
group The number of group in calculating RMSEA
Author(s)
Bell Clinton
Pavel Panko (Texas Tech University; <[Link]@[Link]>)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
findRMSEAsamplesize 39
References
MacCallum, R. C., Browne, M. W., & Cai, L. (2006). Testing differences between nested covari-
ance structure models: Power analysis and null hypotheses. Psychological Methods, 11(1), 19–35.
doi:10.1037/1082989X.11.1.19
See Also
• plotRMSEApowernested to plot the statistical power for nested model comparison based on
population RMSEA given the sample size
• findRMSEAsamplesizenested to find the minium sample size for a given statistical power in
nested model comparison based on population RMSEA
Examples
findRMSEAsamplesize Find the minimum sample size for a given statistical power based on
population RMSEA
Description
Find the minimum sample size for a specified statistical power based on population RMSEA. This
function can be applied for both test of close fit and test of not-close fit (MacCallum, Browne, &
Suguwara, 1996)
Usage
findRMSEAsamplesize(rmsea0, rmseaA, df, power = 0.8, alpha = 0.05, group = 1)
Arguments
rmsea0 Null RMSEA
rmseaA Alternative RMSEA
df Model degrees of freedom
power Desired statistical power to reject misspecified model (test of close fit) or retain
good model (test of not-close fit)
alpha Alpha level used in power calculations
group The number of group that is used to calculate RMSEA.
40 findRMSEAsamplesizenested
Details
This function find the minimum sample size for a specified power based on an iterative routine.
The sample size keep increasing until the calculated power from findRMSEApower function is just
over the specified power. If group is greater than 1, the resulting sample size is the sample size per
group.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
MacCallum, R. C., Browne, M. W., & Sugawara, H. M. (1996). Power analysis and determi-
nation of sample size for covariance structure modeling. Psychological Methods, 1(2), 130–149.
doi:10.1037/1082989X.1.2.130
Jak, S., Jorgensen, T. D., Verdam, M. G., Oort, F. J., & Elffers, L. (2021). Analytical power cal-
culations for structural equation modeling: A tutorial and Shiny app. Behavior Research Methods,
53, 1385–1406. doi:10.3758/s13428020014790
See Also
• plotRMSEApower to plot the statistical power based on population RMSEA given the sample
size
• plotRMSEAdist to visualize the RMSEA distributions
• findRMSEApower to find the statistical power based on population RMSEA given a sample
size
Examples
findRMSEAsamplesizenested
Find sample size given a power in nested model comparison
Description
Find the sample size that the power in rejection the samples from the alternative pair of RMSEA is
just over the specified power.
Usage
findRMSEAsamplesizenested(rmsea0A = NULL, rmsea0B = NULL, rmsea1A,
rmsea1B = NULL, dfA, dfB, power = 0.8, alpha = 0.05, group = 1)
findRMSEAsamplesizenested 41
Arguments
Author(s)
Bell Clinton
Pavel Panko (Texas Tech University; <[Link]@[Link]>)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
MacCallum, R. C., Browne, M. W., & Cai, L. (2006). Testing differences between nested covari-
ance structure models: Power analysis and null hypotheses. Psychological Methods, 11(1), 19–35.
doi:10.1037/1082989X.11.1.19
See Also
• plotRMSEApowernested to plot the statistical power for nested model comparison based on
population RMSEA given the sample size
• findRMSEApowernested to find the power for a given sample size in nested model comparison
based on population RMSEA
Examples
Description
This class contains model fit measures and model fit comparisons among multiple models
Usage
## S4 method for signature 'FitDiff'
show(object)
Arguments
object object of class FitDiff
[Link] character vector naming fit indices the user can request from fitMeasures.
If "default", the fit measures will be c("chisq", "df", "pvalue", "cfi",
"tli","rmsea", "srmr", "aic", "bic"). If "all", all available fit measures
will be returned.
nd number of digits printed
tag single character used to flag the model preferred by each fit index. To omit
tags, set to NULL or NA.
Slots
name character. The name of each model
[Link] character. One class to which each model belongs
nested [Link]. Model fit comparisons between adjacently nested models that are ordered by
their degrees of freedom (df )
fit [Link]. Fit measures of all models specified in the name slot, ordered by their df
[Link] [Link]. Sequential differences in fit measures in the fit slot
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
fmi 43
See Also
compareFit; clipboard
Examples
## Not run:
## Save results to a file
saveFile(measEqOut, file = "[Link]")
## Copy to a clipboard
clipboard(measEqOut)
## End(Not run)
Description
This function estimates the Fraction of Missing Information (FMI) for summary statistics of each
variable, using either an incomplete data set or a list of imputed data sets.
Usage
Arguments
data Either a single [Link] with incomplete observations, or a list of imputed
data sets.
method character. If "saturated" or "sat" (default), the model used to estimate FMI
is a freely estimated covariance matrix and mean vector for numeric variables,
and/or polychoric correlations and thresholds for ordered categorical variables,
for each group (if applicable). If "null", only means and variances are esti-
mated for numeric variables, and/or thresholds for ordered categorical variables
(i.e., covariances and/or polychoric correlations are constrained to zero). See
Details for more information.
group character. The optional name of a grouping variable, to request FMI in each
group.
ords character. Optional vector of names of ordered-categorical variables, which are
not already stored as class ordered in data.
varnames character. Optional vector of variable names, to calculate FMI for a subset of
variables in data. By default, all numeric and ordered variables will be in-
cluded, unless data is a single incomplete [Link], in which case only
numeric variables can be used with FIML estimation. Other variable types will
be removed.
exclude character. Optional vector of variable names to exclude from the analysis.
fewImps logical. If TRUE, use the estimate of FMI that applies a correction to the esti-
mated between-imputation variance. Recommended when there are few impu-
tations; makes little difference when there are many imputations. Ignored when
data is not a list of imputed data sets.
Details
The function estimates a saturated model with lavaan for a single incomplete data set using FIML,
or with [Link] for a list of imputed data sets. If method = "saturated", FMI will be estiamted
for all summary statistics, which could take a lot of time with big data sets. If method = "null", FMI
will only be estimated for univariate statistics (e.g., means, variances, thresholds). The saturated
model gives more reliable estimates, so it could also help to request a subset of variables from a
large data set.
Value
fmi returns a list with at least 2 of the following:
Covariances A list of symmetric matrices: (1) the estimated/pooled covariance matrix, or
a list of group-specific matrices (if applicable) and (2) a matrix of FMI, or
a list of group-specific matrices (if applicable). Only available if method =
"saturated".
Variances The estimated/pooled variance for each numeric variable. Only available if
method = "null" (otherwise, it is on the diagonal of Covariances).
Means The estimated/pooled mean for each numeric variable.
Thresholds The estimated/pooled threshold(s) for each ordered-categorical variable.
message A message indicating caution when the null model is used.
fmi 45
Author(s)
References
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York, NY: Wiley.
Savalei, V. & Rhemtulla, M. (2012). On obtaining estimates of the fraction of missing informa-
tion from full information maximum likelihood. Structural Equation Modeling, 19(3), 477–494.
doi:10.1080/10705511.2012.687669
Wagner, J. (2010). The fraction of missing information as a tool for monitoring the quality of survey
data. Public Opinion Quarterly, 74(2), 223–243. doi:10.1093/poq/nfq007
Examples
## Not run:
## ordered-categorical data
data(datCat)
lapply(datCat, class)
## impose missing values
[Link](123)
for (i in 1:8) datCat[sample(1:nrow(datCat), size = .1*nrow(datCat)), i] <- NA
## impute data m = 3 times
library(Amelia)
[Link](456)
impout <- amelia(datCat, m = 3, noms = "g", ords = paste0("u", 1:8), p2s = FALSE)
imps <- impout$imputations
## calculate FMI, using list of imputed data sets
fmi(imps, group = "g")
## End(Not run)
46 htmt
Description
This function assesses discriminant validity through the heterotrait-monotrait ratio (HTMT) of the
correlations (Henseler, Ringlet & Sarstedt, 2015). Specifically, it assesses the arithmetic (Henseler
et al., ) or geometric (Roemer et al., 2021) mean correlation among indicators across constructs (i.e.
heterotrait–heteromethod correlations) relative to the geometric-mean correlation among indicators
within the same construct (i.e. monotrait–heteromethod correlations). The resulting HTMT(2) val-
ues are interpreted as estimates of inter-construct correlations. Absolute values of the correlations
are recommended to calculate the HTMT matrix, and are required to calculate HTMT2. Correla-
tions are estimated using the lavCor function.
Usage
htmt(model, data = NULL, [Link] = NULL, missing = "listwise",
ordered = NULL, absolute = TRUE, htmt2 = TRUE)
Arguments
model lavaan [Link] of a confirmatory factor analysis model where at least two
factors are required for indicators measuring the same construct.
data A [Link] or data matrix
[Link] A covariance or correlation matrix can be used, instead of data, to estimate the
HTMT values.
missing If "listwise", cases with missing values are removed listwise from the data frame.
If "direct" or "ml" or "fiml" and the estimator is maximum likelihood, an EM al-
gorithm is used to estimate the unrestricted covariance matrix (and mean vector).
If "pairwise", pairwise deletion is used. If "default", the value is set depending
on the estimator and the mimic option (see details in lavCor).
ordered Character vector. Only used if object is a [Link]. Treat these variables
as ordered (ordinal) variables. Importantly, all other variables will be treated as
numeric (unless [Link] in data). (see also lavCor)
absolute logical indicating whether HTMT values should be estimated based on abso-
lute correlations (default is TRUE). This is recommended for HTMT but required
for HTMT2 (so silently ignored).
htmt2 logical indicating whether to use the geometric mean (default, appropriate for
congeneric indicators) or arithmetic mean (which assumes tau-equivalence).
Value
A matrix showing HTMT(2) values (i.e., discriminant validity) between each pair of factors.
imposeStart 47
Author(s)
Ylenio Longo (University of Nottingham; <yleniolongo@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Henseler, J., Ringle, C. M., & Sarstedt, M. (2015). A new criterion for assessing discriminant valid-
ity in variance-based structural equation modeling. Journal of the Academy of Marketing Science,
43(1), 115–135. doi:10.1007/s1174701404038
Roemer, E., Schuberth, F., & Henseler, J. (2021). HTMT2-An improved criterion for assessing
discriminant validity in structural equation modeling. Industrial Management & Data Systems.
doi:10.1108/IMDS0220210082
Voorhees, C. M., Brady, M. K., Calantone, R., & Ramirez, E. (2016). Discriminant validity testing
in marketing: An analysis, causes for concern, and proposed remedies. Journal of the Academy of
Marketing Science, 44(1), 119–134. doi:10.1007/s1174701504554
Examples
Description
This function will save the parameter estimates of a lavaan output and impose those parameter
estimates as starting values for another analysis model. The free parameters with the same names
or the same labels across two models will be imposed the new starting values. This function may
help to increase the chance of convergence in a complex model (e.g., multitrait-multimethod model
or complex longitudinal invariance model).
Usage
imposeStart(out, expr, silent = TRUE)
48 imposeStart
Arguments
out The lavaan output that users wish to use the parameter estimates as staring
values for an analysis model
expr The original code that users use to run a lavaan model
silent Logical to print the parameter table with new starting values
Value
A fitted lavaan model
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Examples
## The following example show that the longitudinal weak invariance model
## using effect coding was not convergent with three time points but convergent
## with two time points. Thus, the parameter estimates from the model with
## two time points are used as starting values of the three time points.
## The model with new starting values is convergent properly.
# Factor Variances
f1t1 ~~ f1t1
f1t2 ~~ f1t2
# Factor Covariances
f1t1 ~~ f1t2
# Error Variances
y1t1 ~~ y1t1
y2t1 ~~ y2t1
y3t1 ~~ y3t1
y1t2 ~~ y1t2
y2t2 ~~ y2t2
y3t2 ~~ y3t2
# Error Covariances
y1t1 ~~ y1t2
y2t1 ~~ y2t2
y3t1 ~~ y3t2
# Factor Means
f1t1 ~ NA*1
f1t2 ~ NA*1
imposeStart 49
# Measurement Intercepts
y1t1 ~ INT1*1
y2t1 ~ INT2*1
y3t1 ~ INT3*1
y1t2 ~ INT4*1
y2t2 ~ INT5*1
y3t2 ~ INT6*1
# Factor Variances
f1t1 ~~ f1t1
f1t2 ~~ f1t2
f1t3 ~~ f1t3
# Factor Covariances
f1t1 ~~ f1t2 + f1t3
f1t2 ~~ f1t3
# Error Variances
y1t1 ~~ y1t1
y2t1 ~~ y2t1
y3t1 ~~ y3t1
y1t2 ~~ y1t2
y2t2 ~~ y2t2
y3t2 ~~ y3t2
y1t3 ~~ y1t3
y2t3 ~~ y2t3
y3t3 ~~ y3t3
# Error Covariances
y1t1 ~~ y1t2
y2t1 ~~ y2t2
y3t1 ~~ y3t2
y1t1 ~~ y1t3
y2t1 ~~ y2t3
y3t1 ~~ y3t3
y1t2 ~~ y1t3
y2t2 ~~ y2t3
y3t2 ~~ y3t3
50 indProd
# Factor Means
f1t1 ~ NA*1
f1t2 ~ NA*1
f1t3 ~ NA*1
# Measurement Intercepts
y1t1 ~ INT1*1
y2t1 ~ INT2*1
y3t1 ~ INT3*1
y1t2 ~ INT4*1
y2t2 ~ INT5*1
y3t2 ~ INT6*1
y1t3 ~ INT7*1
y2t3 ~ INT8*1
y3t3 ~ INT9*1
### Use starting values from the model with two time points
model3time <- imposeStart(model2time, lavaan(weak3time, data = exLong))
summary(model3time)
Description
The indProd function will make products of indicators using no centering, mean centering, double-
mean centering, or residual centering. The orthogonalize function is the shortcut of the indProd
function to make the residual-centered indicators products.
Usage
Arguments
data The desired data to be transformed.
var1 Names or indices of the variables loaded on the first factor
var2 Names or indices of the variables loaded on the second factor
var3 Names or indices of the variables loaded on the third factor (for three-way inter-
action)
match Specify TRUE to use match-paired approach (Marsh, Wen, & Hau, 2004). If
FALSE, the resulting products are all possible products.
meanC Specify TRUE for mean centering the main effect indicator before making the
products
residualC Specify TRUE for residual centering the products by the main effect indicators
(Little, Bovaird, & Widaman, 2006).
doubleMC Specify TRUE for centering the resulting products (Lin et. al., 2010)
namesProd The names of resulting products
Value
The original data attached with the products.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>) Alexander Schoemann (East Carolina Uni-
versity; <schoemanna@[Link]>)
References
Marsh, H. W., Wen, Z. & Hau, K. T. (2004). Structural equation models of latent interactions:
Evaluation of alternative estimation strategies and indicator construction. Psychological Methods,
9(3), 275–300. doi:10.1037/1082989X.9.3.275
Lin, G. C., Wen, Z., Marsh, H. W., & Lin, H. S. (2010). Structural equation models of latent interac-
tions: Clarification of orthogonalizing and double-mean-centering strategies. Structural Equation
Modeling, 17(3), 374–391. doi:10.1080/10705511.2010.488999
Little, T. D., Bovaird, J. A., & Widaman, K. F. (2006). On the merits of orthogonalizing pow-
ered and product terms: Implications for modeling interactions among latent variables. Structural
Equation Modeling, 13(4), 497–519. doi:10.1207/s15328007sem1304_1
See Also
• probe2WayMC For probing the two-way latent interaction when the results are obtained from
mean-centering, or double-mean centering.
• probe3WayMC For probing the three-way latent interaction when the results are obtained from
mean-centering, or double-mean centering.
• probe2WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
52 indProd
• probe3WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• plotProbe Plot the simple intercepts and slopes of the latent interaction.
Examples
## End(Not run)
kd 53
Description
Given a covariance matrix and sample size, generate raw data that correspond to the covariance
matrix. Data can be generated to match the covariance matrix exactly, or to be a sample from the
population covariance matrix.
Usage
kd(covmat, n, type = c("exact", "sample"))
Arguments
covmat a symmetric, positive definite covariance matrix
n the sample size for the data that will be generated
type type of data generation. exact generates data that exactly correspond to covmat.
sample treats covmat as a poulation covariance matrix, generating a sample of
size n.
Details
By default, R’s cov() function divides by n-1. The data generated by this algorithm result in a
covariance matrix that matches covmat, but you must divide by n instead of n-1.
Value
kd returns a data matrix of dimension n by nrow(covmat).
Author(s)
Ed Merkle (University of Missouri; <merklee@[Link]>)
References
Kaiser, H. F. and Dickman, K. (1962). Sample and population score matrices and sample corre-
lation matrices from an arbitrary population correlation matrix. Psychometrika, 27(2), 179–182.
doi:10.1007/BF02289635
Examples
## Get data
dat <- HolzingerSwineford1939[ , 7:15]
hs.n <- nrow(dat)
54 kurtosis
## Generate data of size 300 where covmat is the population covariance matrix
rawdat2 <- kd(covmat, 300)
Description
Finding excessive kurtosis (g2 ) of an object
Usage
kurtosis(object, population = FALSE)
Arguments
object A vector used to find a excessive kurtosis
population TRUE to compute the parameter formula. FALSE to compute the sample statistic
formula.
kurtosis 55
Details
The excessive kurtosis computed by default is g2 , the fourth standardized moment of the empirical
distribution of object. The population parameter excessive kurtosis γ2 formula is
µ4
γ2 = − 3,
µ22
k4
g2 = − 3,
k22
24
V ar(ĝ2 ) =
N
Value
A value of an excessive kurtosis with a test statistic if the population is specified as FALSE
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
Weisstein, Eric W. (n.d.). Kurtosis. Retrived from MathWorld–A Wolfram Web Resource: http:
//[Link]/[Link]
See Also
• skew Find the univariate skewness of a variable
• mardiaSkew Find the Mardia’s multivariate skewness of a set of variables
• mardiaKurtosis Find the Mardia’s multivariate kurtosis of a set of variables
Examples
kurtosis(1:5)
56 [Link]-class
Description
This class extends the lavaanList class, created by fitting a lavaan model to a list of data sets. In
this case, the list of data sets are multiple imputations of missing data.
Usage
## S4 method for signature '[Link]'
show(object)
Arguments
object An object of class [Link]
se, ci, level, standardized, rsquare, header, output
See parameterEstimates. output can also be passed to fitMeasures.
fmi logical indicating whether to include the Fraction Missing Information (FMI)
for parameter estimates in the summary output (see Value section).
scale.W logical. If TRUE (default), the vcov method will calculate the pooled covari-
ance matrix by scaling the within-imputation component by the ARIV (see En-
ders, 2010, p. 235, for definition and formula). Otherwise, the pooled ma-
trix is calculated as the weighted sum of the within-imputation and between-
imputation components (see Enders, 2010, ch. 8, for details). This in turn af-
fects how the summary method calcualtes its pooled standard errors, as well as
the Wald test ([Link]).
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
"improper solutions" such as Heywood cases. NPD solutions are not excluded
by default because they are likely to occur due to sampling error, especially in
small samples. However, gross model misspecification could also cause NPD
solutions, users can compare pooled results with and without this setting as a
sensitivity analysis to see whether some imputations warrant further investiga-
tion. Specific imputation numbers can also be included in this argument, in case
users want to apply their own custom omission criteria (or simulations can use
different numbers of imputations without redundantly refitting the model).
asymptotic logical. If FALSE (typically a default, but see Value section for details using
various methods), pooled tests (of fit or pooled estimates) will be F or t statistics
with associated degrees of freedom (df ). If TRUE, the (denominator) df are as-
sumed to be sufficiently large for a t statistic to follow a normal distribution, so
it is printed as a z statisic; likewise, F times its numerator df is printed, assumed
to follow a χ2 distribution.
[Link], [Link]
See fitMeasures. summary(object, [Link] = TRUE) will print (but
not return) a table of fit measures to the console.
... Additional arguments passed to [Link], or subsequently to lavTestLRT.
58 [Link]-class
total logical (default: TRUE) indicating whether the nobs method should return the
total sample size or (if FALSE) a vector of group sample sizes.
type The meaning of this argument varies depending on which method it it used
for. Find detailed descriptions in the Value section under coef, vcov, and
residuals.
labels logical indicating whether the coef output should include parameter labels.
Default is TRUE.
Value
coef signature(object = "[Link]", type = "free", labels = TRUE, [Link]
= c("[Link]","[Link]")): See lavaan. Returns the pooled point estimates
(i.e., averaged across imputed data sets; see Rubin, 1987).
vcov signature(object = "[Link]", scale.W = TRUE, [Link] = c("[Link]","[Link]"),
type = c("pooled","between","within","ariv")): By default, returns the
pooled covariance matrix of parameter estimates (type = "pooled"), the within-
imputations covariance matrix (type = "within"), the between-imputations co-
variance matrix (type = "between"), or the average relative increase in variance
(type = "ariv") due to missing data.
[Link] signature(object = "[Link]", [Link] = c("[Link]","[Link]")): See
lavaan. Returns model-implied moments, evaluated at the pooled point esti-
mates.
fitted alias for [Link]
residuals signature(object = "[Link]", type = c("raw","cor"), [Link] = c("[Link]","[Link]"))
See lavaan. By default (type = "raw"), returns the difference between the
model-implied moments from [Link] and the pooled observed mo-
ments (i.e., averaged across imputed data sets). Standardized residuals are also
available, using Bollen’s (type = "cor" or "[Link]") or Bentler’s (type =
"[Link]") formulas.
resid alias for residuals
nobs signature(object = "[Link]", total = TRUE): either the total (default)
sample size or a vector of group sample sizes (total = FALSE).
anova signature(object = "[Link]", ...): Returns a test of model fit for a sin-
gle model (object) or test(s) of the difference(s) in fit between nested models
passed via .... See [Link] and compareFit for details.
fitMeasures signature(object = "[Link]", [Link] = "all", [Link]
= NULL, output = "vector", [Link] = c("[Link]","[Link]"), ...): See
lavaan’s fitMeasures for details. Pass additional arguments to [Link]
via ....
fitmeasures alias for fitMeasures.
show signature(object = "[Link]"): returns a message about convergence rates
and estimation problems (if applicable) across imputed data sets.
summary signature(object = "[Link]", se = TRUE, ci = FALSE, level = .95, standardized
= FALSE, rsquare = FALSE, fmi = FALSE, scale.W = !asymptotic, [Link]
= c("[Link]","[Link]"), asymptotic = FALSE, header = TRUE, output = "text",
[Link]-class 59
Slots
coefList list of estimated coefficients in matrix format (one per imputation) as output by lavInspect(fit,
"est")
phiList list of model-implied latent-variable covariance matrices (one per imputation) as output
by lavInspect(fit, "[Link]")
miList list of modification indices output by modindices
seed integer seed set before running imputations
lavListCall call to lavaanList used to fit the model to the list of imputed data sets in @DataList,
stored as a list of arguments
imputeCall call to imputation function (if used), stored as a list of arguments
convergence list of logical vectors indicating whether, for each imputed data set, (1) the model
converged on a solution, (2) SEs could be calculated, (3) the (residual) covariance matrix of
latent variables (Ψ) is non-positive-definite, and (4) the residual covariance matrix of observed
variables (Θ) is non-positive-definite.
lavaanList_slots All remaining slots are from lavaanList, but runMI only populates a subset
of the list slots, two of them with custom information:
DataList The list of imputed data sets
SampleStatsList List of output from lavInspect(fit, "sampstat") applied to each fitted model
ParTableList See lavaanList
vcovList See lavaanList
testList See lavaanList
h1List See lavaanList. An additional element is added to the list: $PT is the "saturated"
model’s parameter table, returned by lav_partable_unrestricted.
baselineList See lavaanList
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Asparouhov, T., & Muthen, B. (2010). Chi-square statistics with multiple imputation. Technical
Report. Retrieved from [Link]
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from
repeated p-values with multiply-imputed data. Statistica Sinica, 1(1), 65–92. Retrieved from
[Link]
Meng, X.-L., & Rubin, D. B. (1992). Performing likelihood ratio tests with multiply-imputed data
sets. Biometrika, 79(1), 103–111. doi:10.2307/2337151
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York, NY: Wiley.
Examples
Description
Provide emmeans support for lavaan objects
Usage
recover_data.lavaan(object, [Link], ...)
Arguments
object An object of class lavaan. See Details.
[Link] character string maming the variable(s) for which expected marginal means /
trends should be produced. A vector of names indicates a multivariate outcome,
treated by default as repeated measures.
... Further arguments passed to emmeans::recover_data.lm or emmeans::emm_basis.lm
trms, xlev, grid
See emmeans::emm_basis
lavaan2emmeans 61
Details
Supported DVs: [Link] must be an endogenous variable, by appearing on the left-hand
side of either a regression operator ("~") or an intercept operator ("~1"), or both.
[Link] can also be a vector of endogenous variable, in which case they will be treated by
emmeans as a multivariate outcome (often, this indicates repeated measures) represented by an
additional factor named [Link] by default. The [Link]= argument can be used to overwrite
this default name.
Unsupported Models: This functionality does not support the following models:
• Multi-level models are not supported.
• Models not fit to a [Link] (i.e., models fit to a covariance matrix).
Dealing with Fixed Parameters: Fixed parameters (set with lavaan’s modifiers) are treated
as-is: their values are set by the users, and they have a SE of 0 (as such, they do not co-vary with
any other parameter).
Dealing with Multigroup Models: If a multigroup model is supplied, a factor is added to the
reference grid, the name matching the group argument supplied when fitting the model. Note that
you must set nesting = NULL.
Dealing with Missing Data: Limited testing suggests that these functions do work when the
model was fit to incomplete data.
Dealing with Factors: By default emmeans recognizes binary variables (0,1) as a "factor" with
two levels (and not a continuous variable). With some clever contrast defenitions it should be
possible to get the desired emmeans / contasts. See example below.
Author(s)
Mattan S. Ben-Shachar (Ben-Gurion University of the Negev; <matanshm@[Link]>)
Examples
## Not run:
library(lavaan)
library(emmeans)
# define mean parameter label for centered math for use in simple slopes
[Link] ~ [Link] * 1
62 lavaan2emmeans
# define variance parameter label for centered math for use in simple slopes
[Link] ~~ [Link] * [Link]
# From lavaan
parameterEstimates(semFit, output = "pretty")[13:15, ]
# Identical slopes.
# SEs differ due to lavaan estimating uncertainty of the mean / SD
# of [Link], whereas emmeans uses the mean+-SD as is (fixed).
[Link] ~ [Link] * 1
V1 := 1 * [Link] + 1 * b1
V2 := 1 * [Link] + 2 * b1
'
## Compare emmeans
# From emmeans
test(
emmeans(semFit, ~ [Link],
[Link] = "LAT1",
at = list([Link] = 1:2))
)
# From lavaan
lavaan2emmeans 63
# metric invariance
dem60 =~ y1 + a*y2 + b*y3 + c*y4
dem65 =~ y5 + a*y6 + b*y7 + c*y8
# scalar invariance
y1 + y5 ~ d*1
y2 + y6 ~ e*1
y3 + y7 ~ f*1
y4 + y8 ~ g*1
# residual correlations
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
## Compare contrasts
# From emmeans
emmeans(semFit, pairwise ~ [Link]|ind60,
[Link] = c("dem60","dem65"),
at = list(ind60 = c(-1,1)))[[2]]
# From lavaan
parameterEstimates(semFit, output = "pretty")[49:50, ]
## Compare contrasts
# From emmeans (note `nesting = NULL`)
emmeans(semFit, pairwise ~ school | ageyr, [Link] = "x1",
at = list(ageyr = c(11, 13, 15)), nesting = NULL)[[2]]
# From lavaan
parameterEstimates(semFit, output = "pretty")
## Compare contrasts
# From lm -> emmeans
lmFit <- lm(breaks ~ wool * tension, data = warpbreaks)
lmEM <- emmeans(lmFit, ~ tension + wool)
contrast(lmEM, method = [Link](L_all = c(-1, .05, 0.5),
M_H = c(0, 1, -1)), by = "wool")
## End(Not run)
Description
Likelihood ratio test (LRT) for lavaan models fitted to multiple imputed data sets. Statistics for
comparing nested models can be calculated by pooling the likelihood ratios across imputed data
sets, as described by Meng & Rubin (1992), or by pooling the LRT statistics from each imputation,
as described by Li, Meng, Raghunathan, & Rubin (1991).
Usage
Arguments
object, h1 An object of class [Link]. object should be nested within (more con-
strained than) h1.
test character indicating which pooling method to use. "D3", "mr", or "[Link]"
(default) requests the method described by Meng & Rubin (1992). "D2", "LMRR",
or "[Link]" requests the complete-data LRT statistic should be calculated
using each imputed data set, which will then be pooled across imputations, as
described in Li, Meng, Raghunathan, & Rubin (1991). Find additional details in
Enders (2010, chapter 8).
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
"improper solutions" such as Heywood cases. Specific imputation numbers can
also be included in this argument, in case users want to apply their own cus-
tom omission criteria (or simulations can use different numbers of imputations
without redundantly refitting the model).
asymptotic logical. If FALSE (default), the pooled test will be returned as an F-distributed
statistic with numerator (df1) and denominator (df2) degrees of freedom. If
TRUE, the pooled F statistic will be multiplied by its df1 on the assumption that
its df2 is sufficiently large enough that the statistic will be asymptotically χ2
distributed with df1.
[Link] logical. Ignored unless test = "D2" and a robust test was requested. If [Link]
= TRUE, the robust test statistic is pooled, whereas [Link] = FALSE will
pool the naive test statistic (or difference statistic) and apply the average scale/shift
parameter to it (unavailable for mean- and variance-adjusted difference statis-
tics, so [Link] will be set TRUE).
... Additional arguments passed to lavTestLRT, only if test = "D2" and [Link]
= TRUE
66 [Link]
Details
The Meng & Rubin (1992) method, also referred to as the "D3" statistic, is only applicable when
using a likelihood-based estimator. Otherwise (e.g., DWLS for categorical outcomes), users are
notified that test was set to "D2".
test = "Mplus" implies "D3" and asymptotic = TRUE (see Asparouhov & Muthen, 2010).
Note that unlike lavTestLRT, lavTestLRT can only be used to compare a single pair of models,
not a longer list of models. To compare several nested models fitted to multiple imputations, see
examples on the compareFit help page.
Value
A vector containing the LRT statistic (either an F or χ2 statistic, depending on the asymptotic
argument), its degrees of freedom (numerator and denominator, if asymptotic = FALSE), its p value,
and 2 missing-data diagnostics: the relative invrease in variance (RIV, or average for multiparameter
tests: ARIV) and the fraction missing information (FMI = ARIV / (1 + ARIV)). Robust statistics
will also include the average (across imputations) scaling factor and (if relevant) shift parameter(s),
unless [Link] = TRUE.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from
repeated p-values with multiply-imputed data. Statistica Sinica, 1(1), 65–92. Retrieved from
[Link]
Meng, X.-L., & Rubin, D. B. (1992). Performing likelihood ratio tests with multiply-imputed data
sets. Biometrika, 79(1), 103–111. doi:10.2307/2337151
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York, NY: Wiley.
See Also
lavTestLRT, compareFit
Examples
## Not run:
## impose missing data for example
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
[Link](12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
library(Amelia)
[Link](12345)
[Link] <- amelia(HSMiss, m = 20, noms = "school", p2s = FALSE)
imps <- [Link]$imputations
## Using D2, you can either robustify the pooled naive statistic ...
[Link](fit1, h1 = fit0, asymptotic = TRUE, test = "D2")
## ... or pool the robust chi-squared statistic
[Link](fit1, h1 = fit0, asymptotic = TRUE, test = "D2",
[Link] = TRUE)
## End(Not run)
Description
Score test (or "Lagrange multiplier" test) for lavaan models fitted to multiple imputed data sets.
Statistics for releasing one or more fixed or constrained parameters in model can be calculated
by pooling the gradient and information matrices pooled across imputed data sets in a method
proposed by Mansolf, Jorgensen, & Enders (2020)—analogous to the "D1" Wald test proposed by
Li, Meng, Raghunathan, & Rubin’s (1991)—or by pooling the complete-data score-test statistics
across imputed data sets (i.e., "D2"; Li et al., 1991).
Usage
Arguments
with add), if all constraints were released. For EPCs associated with a partic-
ular (1-df ) constraint, only specify one parameter in add or one constraint in
release.
standardized If TRUE, two extra columns ([Link] and [Link]) in the $epc table will con-
tain standardized values for the EPCs. See lavTestScore.
[Link] logical. See standardizedSolution.
verbose logical. Not used for now.
warn logical. If TRUE, print warnings if they occur.
information character indicating the type of information matrix to use (check lavInspect
for available options). "expected" information is the default, which provides
better control of Type I errors.
Value
A list containing at least one [Link]:
• $test: The total score test, with columns for the score test statistic (X2), its degrees of freedom
(df), its p value under the χ2 distribution ([Link]), and if asymptotic=FALSE, the average
relative invrease in variance (ARIV) used to calculate the denominator df is also returned as
a missing-data diagnostic, along with the fraction missing information (FMI = ARIV / (1 +
ARIV)).
• $uni: Optional (if univariate=TRUE). Each 1-df score test, equivalent to modification in-
dices. Also includes EPCs if epc=TRUE, and RIV and FMI if asymptotic=FALSE.
• $cumulative: Optional (if cumulative=TRUE). Cumulative score tests, with ARIV and FMI
if asymptotic=FALSE.
• $epc: Optional (if epc=TRUE). Parameter estimates, expected parameter changes, and expected
parameter values if ALL the tested constraints were freed.
See lavTestScore for details.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Adapted from lavaan source code, written by Yves Rosseel (Ghent University; <[Link]@[Link]>)
test = "D1" method proposed by Maxwell Mansolf (University of California, Los Angeles; <mamansolf@[Link]>)
References
Bentler, P. M., & Chou, C.-P. (1992). Some new covariance structure model improvement statistics.
Sociological Methods & Research, 21(2), 259–282. doi:10.1177/0049124192021002006
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from
repeated p-values with multiply-imputed data. Statistica Sinica, 1(1), 65–92. Retrieved from
[Link]
Mansolf, M., Jorgensen, T. D., & Enders, C. K. (2020). A multiple imputation score test for model
modification in structural equation models. Psychological Methods, 25(4), 393–411. doi:10.1037/
met0000243
70 [Link]
See Also
lavTestScore
Examples
## Not run:
## impose missing data for example
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
[Link](12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
## End(Not run)
Description
Wald test for testing a linear hypothesis about the parameters of lavaan models fitted to multiple
imputed data sets. Statistics for constraining one or more free parameters in a model can be calcu-
lated from the pooled point estimates and asymptotic covariance matrix of model parameters using
Rubin’s (1987) rules, or by pooling the Wald test statistics across imputed data sets (Li, Meng,
Raghunathan, & Rubin, 1991).
[Link] 71
Usage
[Link](object, constraints = NULL, test = c("D1", "D2"),
asymptotic = FALSE, scale.W = !asymptotic, [Link] = c("[Link]",
"[Link]"), verbose = FALSE, warn = TRUE)
Arguments
object An object of class [Link].
constraints A character string (typically between single quotes) containing one or more
equality constraints. See examples for more details
test character indicating which pooling method to use. "D1" or "Rubin" (default)
indicates Rubin’s (1987) rules will be applied to the point estimates and the
asymptotic covariance matrix of model parameters, and those pooled values
will be used to calculate the Wald test in the usual manner. "D2", "LMRR", or
"[Link]" indicate that the complete-data Wald test statistic should be calcu-
lated using each imputed data set, which will then be pooled across imputations,
as described in Li, Meng, Raghunathan, & Rubin (1991) and Enders (2010,
chapter 8).
asymptotic logical. If FALSE (default), the pooled test will be returned as an F-distributed
statistic with numerator (df1) and denominator (df2) degrees of freedom. If
TRUE, the pooled F statistic will be multiplied by its df1 on the assumption that
its df2 is sufficiently large enough that the statistic will be asymptotically χ2
distributed with df1.
scale.W logical. If FALSE, the pooled asymptotic covariance matrix of model param-
eters is calculated as the weighted sum of the within-imputation and between-
imputation components. Otherwise, the pooled asymptotic covariance matrix
of model parameters is calculated by scaling the within-imputation component
by the average relative increase in variance (ARIV; see Enders, 2010, p. 235),
which is only consistent when requesting the F test (i.e., asymptotic = FALSE.
Ignored (irrelevant) if test = "D2".
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
"improper solutions" such as Heywood cases. Specific imputation numbers can
also be included in this argument, in case users want to apply their own cus-
tom omission criteria (or simulations can use different numbers of imputations
without redundantly refitting the model).
verbose logical. If TRUE, print the restriction matrix and the estimated restricted values.
warn logical. If TRUE, print warnings if they occur.
Details
The constraints are specified using the "==" operator. Both the left-hand side and the right-hand side
of the equality can contain a linear combination of model parameters, or a constant (like zero). The
72 [Link]
model parameters must be specified by their user-specified labels from the link[lavaan]{[Link]}.
Names of defined parameters (using the ":=" operator) can be included too.
Value
A vector containing the Wald test statistic (either an F or χ2 statistic, depending on the asymptotic
argument), the degrees of freedom (numerator and denominator, if asymptotic = FALSE), and a p
value. If asymptotic = FALSE, the relative invrease in variance (RIV, or average for multiparameter
tests: ARIV) used to calculate the denominator df is also returned as a missing-data diagnostic,
along with the fraction missing information (FMI = ARIV / (1 + ARIV)).
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Adapted from lavaan source code, written by Yves Rosseel (Ghent University; <[Link]@[Link]>)
References
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from
repeated p-values with multiply-imputed data. Statistica Sinica, 1(1), 65–92. Retrieved from
[Link]
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York, NY: Wiley.
See Also
lavTestWald
Examples
## Not run:
## impose missing data for example
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
[Link](12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
'
## End(Not run)
Description
Find standardized factor loading from coefficient alpha assuming that all items have equal loadings.
Usage
loadingFromAlpha(alpha, ni)
Arguments
alpha A desired coefficient alpha value.
ni A desired number of items.
Value
result The standardized factor loadings that make desired coefficient alpha with speci-
fied number of items.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
74 lrv2ord
Examples
loadingFromAlpha(0.8, 4)
Description
This function calculates ordinal-scale moments implied by LRV-scale moments
Usage
lrv2ord(Sigma, Mu, thresholds, cWts)
Arguments
Sigma Population covariance matrix, with variable names saved in the dimnames at-
tribute.
Mu Optional numeric vector of population means. If missing, all means will be set
to zero.
thresholds Either a single numeric vector of population thresholds used to discretize each
normally distributed variable, or a named list of each discretized variable’s
vector of thresholds. The discretized variables may be a subset of all variables
in Sigma if the remaining variables are intended to be observed rather than latent
normally distributed variables.
cWts Optional (default when missing is to use 0 for the lowest category, followed by
successive integers for each higher category). Either a single numeric vector of
category weights (if they are identical across all variables) or a named list of
each discretized variable’s vector of category weights.
Details
Binary and ordinal data are frequently accommodated in SEM by incorporating a threshold model
that links each observed categorical response variable to a corresponding latent response variable
that is typically assumed to be normally distributed (Kamata & Bauer, 2008; Wirth & Edwards,
2007).
Value
A list including the LRV-scale population moments (means, covariance matrix, correlation ma-
trix, and thresholds), the category weights, a [Link] of implied univariate moments (means,
SDs, skewness, and excess kurtosis (i.e., in excess of 3, which is the kurtosis of the normal distri-
bution) for discretized data treated as numeric, and the implied covariance and correlation matrix
of discretized data treated as numeric.
lrv2ord 75
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Andrew Johnson (Curtin University; <[Link]@[Link]>)
References
Kamata, A., & Bauer, D. J. (2008). A note on the relation between factor analytic and item response
theory models. Structural Equation Modeling, 15(1), 136–153. doi:10.1080/10705510701758406
Wirth, R. J., & Edwards, M. C. (2007). Item factor analysis: Current approaches and future direc-
tions. Psychological Methods, 12(1), 58–79. doi:10.1037/1082989X.12.1.58
Examples
Description
Finding Mardia’s multivariate kurtosis of multiple variables
Usage
mardiaKurtosis(dat, use = "everything")
Arguments
dat The target matrix or data frame with multiple variables
use Missing data handling method from the cov function.
Details
The Mardia’s multivariate kurtosis formula (Mardia, 1970) is
n
1 Xh 0 i 2
b2,d = Xi − X̄ S −1 Xi − X̄ ,
n i=1
where d is the number of variables, X is the target dataset with multiple variables, n is the sample
size, S is the sample covariance matrix of the target dataset, and X̄ is the mean vectors of the
target dataset binded in n rows. When the population multivariate kurtosis is normal, the b2,d
is asymptotically distributed as normal distribution with the mean of d(d + 2) and variance of
8d(d + 2)/n.
Value
A value of a Mardia’s multivariate kurtosis with a test statistic
mardiaSkew 77
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
Mardia, K. V. (1970). Measures of multivariate skewness and kurtosis with applications. Biometrika,
57(3), 519–530. doi:10.2307/2334770
See Also
• skew Find the univariate skewness of a variable
• kurtosis Find the univariate excessive kurtosis of a variable
• mardiaSkew Find the Mardia’s multivariate skewness of a set of variables
Examples
library(lavaan)
mardiaKurtosis(HolzingerSwineford1939[ , paste0("x", 1:9)])
Description
Finding Mardia’s multivariate skewness of multiple variables
Usage
mardiaSkew(dat, use = "everything")
Arguments
dat The target matrix or data frame with multiple variables
use Missing data handling method from the cov function.
Details
The Mardia’s multivariate skewness formula (Mardia, 1970) is
n n
1 XXh 0 −1 i3
b1,d = X i − X̄ S Xj − X̄ ,
n2 i=1 j=1
where d is the number of variables, X is the target dataset with multiple variables, n is the sample
size, S is the sample covariance matrix of the target dataset, and X̄ is the mean vectors of the
target dataset binded in n rows. When the population multivariate skewness is normal, the n6 b1,d is
asymptotically distributed as χ2 distribution with d(d + 1)(d + 2)/6 degrees of freedom.
78 maximalRelia
Value
A value of a Mardia’s multivariate skewness with a test statistic
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
Mardia, K. V. (1970). Measures of multivariate skewness and kurtosis with applications. Biometrika,
57(3), 519–530. doi:10.2307/2334770
See Also
• skew Find the univariate skewness of a variable
• kurtosis Find the univariate excessive kurtosis of a variable
• mardiaKurtosis Find the Mardia’s multivariate kurtosis of a set of variables
Examples
library(lavaan)
mardiaSkew(HolzingerSwineford1939[ , paste0("x", 1:9)])
Description
Calculate maximal reliability of a scale
Usage
maximalRelia(object, [Link] = c("[Link]", "[Link]"))
Arguments
object A lavaan or [Link] object, expected to contain only exogenous common
factors (i.e., a CFA model).
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
"improper solutions" such as Heywood cases. NPD solutions are not excluded
maximalRelia 79
by default because they are likely to occur due to sampling error, especially in
small samples. However, gross model misspecification could also cause NPD
solutions, users can compare pooled results with and without this setting as a
sensitivity analysis to see whether some imputations warrant further investiga-
tion.
Details
Given that a composite score (W ) is a weighted sum of item scores:
W = w0 x,
where x is a k × 1 vector of the scores of each item, w is a k × 1 weight vector of each item,
and k represents the number of items. Then, maximal reliability is obtained by finding w such that
reliability attains its maximum (Li, 1997; Raykov, 2012). Note that the reliability can be obtained
by
w0 ST w
ρ=
w0 SX w
where ST is the covariance matrix explained by true scores and SX is the observed covariance
matrix. Numerical method is used to find w in this function.
For continuous items, ST can be calculated by
ST = ΛΨΛ0 ,
where Λ is the factor loading matrix and Ψ is the covariance matrix among factors. SX is directly
obtained by covariance among items.
For categorical items, Green and Yang’s (2009) method is used for calculating ST and SX . The
element i and j of ST can be calculated by
i −1 C
CX j −1 i −1
CX Cj −1
X X
[ST ]ij = Φ2 τxci , τxcj , [ΛΨΛ0 ]ij − Φ1 (τxci ) Φ1 (τxcj ),
ci =1 cj −1 ci =1 cj −1
where Ci and Cj represents the number of thresholds in Items i and j, τxci represents the threshold
ci of Item i, τxcj represents the threshold ci of Item j, Φ1 (τxci ) is the cumulative probability of
τxci given a univariate standard normal cumulative distribution and Φ2 τxci , τxcj , ρ is the joint
cumulative probability of τxci and τxcj given a bivariate standard normal cumulative distribution
with a correlation of ρ
Each element of SX can be calculated by
i −1 C
CX j −1 i −1
CX Cj −1
X X
[ST ]ij = Φ2 τVci , τVcj , ρ∗ij − Φ1 (τVci ) Φ1 (τVcj ),
ci =1 cj −1 ci =1 cj −1
Value
Maximal reliability values of each group. The maximal-reliability weights are also provided. Users
may extracted the weighted by the attr function (see example below).
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
Li, H. (1997). A unifying expression for the maximal reliability of a linear composite. Psychome-
trika, 62(2), 245–249. doi:10.1007/BF02295278
Raykov, T. (2012). Scale construction and development using structural equation modeling. In
R. H. Hoyle (Ed.), Handbook of structural equation modeling (pp. 472–494). New York, NY:
Guilford.
See Also
reliability for reliability of an unweighted composite score
Examples
Description
Automatically generates lavaan model syntax to specify a confirmatory factor analysis (CFA)
model with equality constraints imposed on user-specified measurement (or structural) parame-
ters. Optionally returns the fitted model (if data are provided) representing some chosen level of
measurement equivalence/invariance across groups and/or repeated measures.
Usage
[Link]([Link], ..., [Link] = "[Link]",
[Link] = "[Link].2016", [Link] = c(1L, 2L), group = NULL,
[Link] = "", [Link] = "", longFacNames = list(),
longIndNames = list(), [Link] = "", [Link] = "",
auto = "all", warn = TRUE, debug = FALSE, [Link] = FALSE)
[Link] 81
Arguments
[Link]
A model with no measurement-invariance constraints (i.e., representing only
configural invariance), unless required for model identification. [Link]
can be either:
• lavaan [Link] or a parameter table (as returned by parTable) spec-
ifying the configural model. Using this option, the user can also provide
either raw data or summary statistics via [Link] and (optionally)
[Link]. See argument descriptions in lavaan. In order to include
thresholds in the generated syntax, either users must provide raw data, or
the [Link] syntax must specify all thresholds (see first exam-
ple). If raw data are not provided, the number of blocks (groups, levels, or
combination) must be indicated using an arbitrary [Link] argument
(e.g., 3 groups could be specified using [Link]=rep(1, 3)).
• a fitted lavaan model (e.g., as returned by cfa) estimating the configural
model
Note that the specified or fitted model must not contain any latent structural pa-
rameters (i.e., it must be a CFA model), unless they are higher-order constructs
with latent indicators (i.e., a second-order CFA).
... Additional arguments (e.g., data, ordered, or parameterization) passed to
the lavaan function. See also lavOptions.
[Link] character. The method for identifying common-factor variances and (if meanstructure
= TRUE) means. Three methods are available, which go by different names in the
literature:
• Standardize the common factor (mean = 0, SD = 1) by specifying any of:
"[Link]", "[Link]", "UV", "[Link]", "fixed-factor"
• Choose a reference indicator by specifying any of: "[Link]",
"[Link]", "UL", "marker", "ref", "[Link]", "[Link]",
"reference-indicator", "[Link]", "marker-variable"
• Apply effects-code constraints to loadings and intercepts by specifying any
of: "FX", "EC", "effects", "[Link]", "effects-coding", "[Link]",
"effects-code"
See Kloessner & Klopp (2019) for details about all three methods.
[Link] character. The method for identifying (residual) variances and intercepts of la-
tent item-responses underlying any ordered indicators. Four methods are avail-
able:
• To follow Wu & Estabrook’s (2016) guidelines (default), specify any of:
"[Link].2016", "Wu.2016", "[Link]", "Wu", "Wu2016".
For consistency, specify [Link] = "[Link]".
• To use the default settings of Mplus and lavaan, specify any of: "default",
"Mplus", "Muthen". Details provided in Millsap & Tein (2004).
• To use the constraints recommended by Millsap & Tein (2004; see also
Liu et al., 2017, for the longitudinal case) specify any of: "millsap",
"millsap.2004", "[Link].2004". For consistency, specify [Link]
= "marker" and parameterization = "theta".
82 [Link]
Details
This function is a pedagogical and analytical tool to generate model syntax representing some level
of measurement equivalence/invariance across any combination of multiple groups and/or repeated
measures. Support is provided for confirmatory factor analysis (CFA) models with simple or com-
plex structure (i.e., cross-loadings and correlated residuals are allowed). For any complexities that
exceed the limits of automation, this function is intended to still be useful by providing a means to
generate syntax that users can easily edit to accommodate their unique situations.
Limited support is provided for bifactor models and higher-order constructs. Because bifactor mod-
els have cross-loadings by definition, the option [Link] = "[Link]" is unavailable. [Link]
= "UV" is recommended for bifactor models, but [Link] = "UL" is available on the condition that
each factor has a unique first indicator in the [Link]. In order to maintain generality,
higher-order factors may include a mix of manifest and latent indicators, but they must therefore
require [Link] = "UL" to avoid complications with differentiating lower-order vs. higher-order (or
mixed-level) factors. The keyword "loadings" in [Link] or [Link] constrains fac-
tor loadings of all manifest indicators (including loadings on higher-order factors that also have
latent indicators), whereas the keyword "regressions" constrains factor loadings of latent indica-
tors. Users can edit the model syntax manually to adjust constraints as necessary, or clever use of
the [Link] or [Link] arguments could make it possible for users to still automated
their model syntax. The keyword "intercepts" constrains the intercepts of all manifest indicators,
and the keyword "means" constrains intercepts and means of all latent common factors, regardless
of whether they are latent indicators of higher-order factors. To test equivalence of lower-order and
higher-order intercepts/means in separate steps, the user can either manually edit their generated
syntax or conscientiously exploit the [Link] or [Link] arguments as necessary.
[Link]: If the [Link] fixes any (e.g., the first) factor loadings, the generated syntax
object will retain those fixed values. This allows the user to retain additional constraints that might
be necessary (e.g., if there are only 1 or 2 indicators). Some methods must be used in conjunction
with other settings:
[Link]: Wu & Estabrook (2016) recommended constraining thresholds to equality first, and doing
so should allow releasing any identification constraints no longer needed. For each ordered indica-
tor, constraining one threshold to equality will allow the item’s intercepts to be estimated in all but
the first group or repeated measure. Constraining a second threshold (if applicable) will allow the
item’s (residual) variance to be estimated in all but the first group or repeated measure. For binary
data, there is no independent test of threshold, intercept, or residual-variance equality. Equivalence
of thresholds must also be assumed for three-category indicators. These guidelines provide the least
restrictive assumptions and tests, and are therefore the default.
The default setting in Mplus is similar to Wu & Estabrook (2016), except that intercepts are always
constrained to zero (so they are assumed to be invariant without testing them). Millsap & Tein
(2004) recommended parameterization = "theta" and identified an item’s residual variance in
all but the first group (or occasion; Liu et al., 2017) by constraining its intercept to zero and one of
its thresholds to equality. A second threshold for the reference indicator (so [Link] = "UL") is used
to identify the common-factor means in all but the first group/occasion. The LISREL software fixes
the first threshold to zero and (if applicable) the second threshold to 1, and assumes any remaining
84 [Link]
thresholds to be equal across groups / repeated measures; thus, the intercepts are always identified,
and residual variances (parameterization = "theta") are identified except for binary data, when
they are all fixed to one.
Repeated Measures: If each repeatedly measured factor is measured by the same indicators (speci-
fied in the same order in the [Link]) on each occasion, without any cross-loadings, the
user can let longIndNames be automatically generated. Generic names for the repeatedly measured
indicators are created using the name of the repeatedly measured factors (i.e., names(longFacNames))
and the number of indicators. So the repeatedly measured first indicator ("ind") of a longitudinal
construct called "factor" would be generated as "._factor_ind.1".
The same types of parameter can be specified for [Link] as for [Link] (see lavOptions
for a list), except for "[Link]" or "[Link]". Instead, users can con-
strain autocovariances using keywords "[Link]" or "[Link]". Note that [Link]
= "[Link]" or [Link] = "[Link]" will constrain any autocovari-
ances across groups, along with any other covariances the user specified in the [Link].
Note also that autocovariances cannot be specified as exceptions in [Link], so anything
more complex than the auto argument automatically provides should instead be manually specified
in the [Link].
When users set orthogonal=TRUE in the [Link] (e.g., in bifactor models of repeat-
edly measured constructs), autocovariances of each repeatedly measured factor will still be freely
estimated in the generated syntax.
Missing Data: If users wish to utilize the auxiliary function to automatically include auxil-
iary variables in conjunction with missing = "FIML", they should first generate the hypothesized-
model syntax, then submit that syntax as the model to auxiliary(). If users utilized runMI
to fit their [Link] to multiply imputed data, that model can also be passed to the
[Link] argument, and if [Link] = TRUE, the generated model will be fitted to
the multiple imputations.
Value
By default, an object of class [Link]. If [Link] = TRUE, a fitted lavaan model, with
the [Link] object stored in the @external slot, accessible by fit@external$[Link].
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Kloessner, S., & Klopp, E. (2019). Explaining constraint interaction: How to interpret estimated
model parameters under alternative scaling methods. Structural Equation Modeling, 26(1), 143–
155. doi:10.1080/10705511.2018.1517356
Liu, Y., Millsap, R. E., West, S. G., Tein, J.-Y., Tanaka, R., & Grimm, K. J. (2017). Testing measure-
ment invariance in longitudinal data with ordered-categorical measures. Psychological Methods,
22(3), 486–506. doi:10.1037/met0000075
Millsap, R. E., & Tein, J.-Y. (2004). Assessing factorial invariance in ordered-categorical measures.
Multivariate Behavioral Research, 39(3), 479–515. doi:10.1207/S15327906MBR3903_4
[Link] 85
Wu, H., & Estabrook, R. (2016). Identification of confirmatory factor analysis models of dif-
ferent levels of invariance for ordered categorical outcomes. Psychometrika, 81(4), 1014–1045.
doi:10.1007/s1133601695060
See Also
compareFit
Examples
[Link] <- ' FU1 =~ u1 + u2 + u3 + u4
FU2 =~ u5 + u6 + u7 + u8 '
## the 2 factors are actually the same factor (FU) measured twice
longFacNames <- list(FU = c("FU1","FU2"))
## THRESHOLD invariance:
## only necessary to specify thresholds if you have no data
[Link] <- '
u1 | t1 + t2 + t3 + t4
u2 | t1 + t2 + t3 + t4
u3 | t1 + t2 + t3 + t4
u4 | t1 + t2 + t3 + t4
u5 | t1 + t2 + t3 + t4
u6 | t1 + t2 + t3 + t4
u7 | t1 + t2 + t3 + t4
u8 | t1 + t2 + t3 + t4
'
[Link] <- [Link]([Link] = c([Link], [Link]),
# NOTE: data not provided, so syntax must
# include thresholds, and number of
# groups == 2 is indicated by:
[Link] = c(1, 1),
parameterization = "theta",
[Link] = "[Link]", [Link] = "[Link].2016",
group = "g", [Link] = "thresholds",
longFacNames = longFacNames,
[Link] = "thresholds")
## notice that constraining 4 thresholds allows intercepts and residual
86 [Link]
## variances to be freely estimated in all but the first group & occasion
cat([Link]([Link]))
## print a summary of model features
summary([Link])
## --------------------------------------------------------
## RECOMMENDED PRACTICE: fit one invariance model at a time
## --------------------------------------------------------
## The recommended sequence is to (1) generate and save each syntax object,
## (2) print it to the screen to verify you are fitting the model you expect
## to (and potentially learn which identification constraints should be
## released when equality constraints are imposed), and (3) fit that model
## to the data, as you would if you had written the syntax yourself.
## Not run:
## metric invariance
[Link] <- [Link]([Link] = [Link], data = datCat,
[Link] 87
## scalar invariance
[Link] <- [Link]([Link] = [Link], data = datCat,
ordered = paste0("u", 1:8),
parameterization = "theta",
[Link] = "[Link]", [Link] = "[Link].2016",
group = "g", longFacNames = longFacNames,
[Link] = c("thresholds","loadings",
"intercepts"),
[Link] = c("thresholds","loadings",
"intercepts"))
summary([Link]) # summarize model features
[Link] <- [Link]([Link]) # save as text
cat([Link]) # print/view lavaan syntax
## fit model to data
[Link] <- cfa([Link], data = datCat, group = "g",
ordered = paste0("u", 1:8), parameterization = "theta")
## test equivalence of intercepts, given equal thresholds & loadings
anova([Link], [Link])
## For a single table with all results, you can pass the models to
## summarize to the compareFit() function
compareFit([Link], [Link], [Link], [Link])
## ------------------------------------------------------
## NOT RECOMMENDED: fit several invariance models at once
## ------------------------------------------------------
[Link] <- c("thresholds","loadings","intercepts","means","residuals")
[Link] <- list()
for (i in 0:length([Link])) {
if (i == 0L) {
[Link] <- "configural"
[Link] <- ""
[Link] <- ""
} else {
[Link] <- [Link][i]
88 [Link]
compareFit([Link])
## -----------------
## Binary indicators
## -----------------
#longFacNames = longFacNames,
#[Link] = [Link],
[Link] = TRUE)
}
compareFit([Link])
## ---------------------
## Multilevel Invariance
## ---------------------
## End(Not run)
Description
This class of object stores information used to automatically generate lavaan model syntax to rep-
resent user-specified levels of measurement equivalence/invariance across groups and/or repeated
measures. See [Link] for details.
Usage
## S4 method for signature '[Link]'
[Link](x, package = "lavaan",
params = NULL, single = TRUE, [Link] = FALSE)
90 [Link]-class
Arguments
x, object an object of class [Link]
package character indicating the package for which the model syntax should be gener-
ated. Currently, only "lavaan" and "mplus" are supported.
params character vector indicating which type(s) of parameter to print syntax for.
Must match a type that can be passed to [Link] or [Link], but
"[Link]" and "[Link]" will be silently ignored.
Instead, requesting "residuals" or "[Link]" will return covariances
along with variances. By default (NULL), all types are printed.
single logical indicating whether to concatenate lavaan [Link] into a single
character string. Setting FALSE will return a vector of strings, which may be
convenient (or even necessary to prevent an error) in models with long variable
names, many variables, or many groups.
[Link]
logical indicating whether to write lavaan [Link] using vectors of la-
bels and values for multiple groups (the default: FALSE), or whether to write
a separate "block" of syntax per group. The block structure could allow users
to apply the generated multigroup syntax (after some editing) to test invariance
across levels in a multilevel SEM (see final example on [Link] help
page).
verbose logical indicating whether to print a summary to the screen (default). If FALSE,
only a pattern matrix is returned.
... Additional arguments to the call, or arguments with changed values.
evaluate If TRUE, evaluate the new call; otherwise, return the new call.
[Link] lavaan [Link] specifying labels or fixed/free values of parameters in
object. These provide some flexibility to customize existing parameters with-
out having to copy/paste the output of [Link](object) into an R script.
For example, [Link] will free a parameter across all groups, but update
allows users to free the parameter in just one group while maintaining equality
constraints among other groups.
Value
summary signature(object = "[Link]", verbose = TRUE): A character ma-
trix indicating the pattern of numeric, ordered, or latent indicators loading on
common factors. By default (verbose = TRUE), summary also prints descriptive
[Link]-class 91
details about the model, including the numbers of indicators and factors, and
which parameters are constrained to equality.
show signature(object = "[Link]"): Prints a message about how to use
the object for model fitting. Invisibly returns the object.
update signature(object = "[Link]", ..., evaluate = TRUE, [Link]
= NULL): Creates a new object with updated arguments in ..., or updated pa-
rameter labels or fixed/free specifications in object.
[Link] signature(x = "[Link]", package = "lavaan"): Converts the [Link]
object to model syntax that can be copy/pasted or written to a syntax file to
be edited before analysis, or simply passed to lavaan to fit the model to data.
Generated Mplus syntax could also be utilized using the MplusAuthomation
package.
Slots
package character indicating the software package used to represent the model. Currently, only
"lavaan" is available, which uses the LISREL representation (see lavOptions). In the future,
"OpenMx" may become available, using RAM representation.
[Link] character. Currently, only "cfa" is available. Future versions may allow for MIMIC
/ RFA models, where invariance can be tested across levels of exogenous variables explicitly
included as predictors of indicators, controlling for their effects on (or correlation with) the
common factors.
call The function call as returned by [Link](), with some arguments updated if necessary
for logical consistency.
meanstructure logical indicating whether a mean structure is included in the model.
numeric character vector naming numeric manifest indicators.
ordered character vector naming ordered indicators.
parameterization character. See lavOptions.
specify list of parameter matrices, similar in form to the output of lavInspect(fit, "free").
These matrices are logical, indicating whether each parameter should be specified in the
model syntax.
values list of parameter matrices, similar in form to the output of lavInspect(fit, "free").
These matrices are numeric, indicating whether each parameter should be freely estimated
(indicated by NA) or fixed to a particular value.
labels list of parameter matrices, similar in form to the output of lavInspect(fit, "free").
These matrices contain character labels used to constrain parameters to equality.
constraints character vector containing additional equality constraints used to identify the
model when [Link] = "fx".
ngroups integer indicating the number of groups.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
92 miPowerFit
Examples
## See ?[Link] help page for examples using lavaan
miPowerFit Modification indices and their power approach for model fit evaluation
Description
The model fit evaluation approach using modification indices and expected parameter changes.
Usage
miPowerFit(lavaanObj, stdLoad = 0.4, cor = 0.1, stdBeta = 0.1,
intcept = 0.2, stdDelta = NULL, delta = NULL, cilevel = 0.9, ...)
Arguments
lavaanObj The lavaan model object used to evaluate model fit
stdLoad The amount of standardized factor loading that one would like to be detected
(rejected). The default value is 0.4, which is suggested by Saris and colleagues
(2009, p. 571).
cor The amount of factor or error correlations that one would like to be detected
(rejected). The default value is 0.1, which is suggested by Saris and colleagues
(2009, p. 571).
stdBeta The amount of standardized regression coefficients that one would like to be
detected (rejected). The default value is 0.1, which is suggested by Saris and
colleagues (2009, p. 571).
intcept The amount of standardized intercept (similar to Cohen’s d that one would like
to be detected (rejected). The default value is 0.2, which is equivalent to a low
effect size proposed by Cohen (1988, 1992).
stdDelta The vector of the standardized parameters that one would like to be detected
(rejected). If this argument is specified, the value here will overwrite the other
arguments above. The order of the vector must be the same as the row order
from modification indices from the lavaan object. If a single value is specified,
the value will be applied to all parameters.
delta The vector of the unstandardized parameters that one would like to be detected
(rejected). If this argument is specified, the value here will overwrite the other
arguments above. The order of the vector must be the same as the row order
from modification indices from the lavaan object. If a single value is specified,
the value will be applied to all parameters.
cilevel The confidence level of the confidence interval of expected parameter changes.
The confidence intervals are used in the equivalence testing.
... arguments passed to modificationIndices, except for delta, which is already
an argument (which can be substituted for stdDelta or specific sets of parame-
ters using stdLoad, cor, stdBeta, and intcept).
miPowerFit 93
Details
To decide whether a parameter should be freed, one can inspect its modification index (MI) and
expected parameter change (EPC). Those values can be used to evaluate model fit by 2 methods.
Method 1: Saris, Satorra, and van der Veld (2009, pp. 570–573) used power (probability of detecting
a significant MI) and EPC to decide whether to free a parametr. First, one should evaluate whether
a parameter’s MI is significant. Second, one should evaluate whether the power to detect a target
EPC is high enough. The combination of criteria leads to the so-called "JRule" first implemented
with LISREL (van der Veld et al., 2008):
• If the MI is not significant and the power is low, the test is inconclusive.
• If the MI is not significant and the power is high, there is no misspecification.
• If the MI is significant and the power is low, the fixed parameter is misspecified.
• If the MI is significant and the power is high, the EPC is investigated. If the EPC is large
(greater than the the target EPC), the parameter is misspecified. If the EPC is low (lower than
the target EPC), the parameter is not misspecificied.
Method 2: The confidence interval (CI) of an EPC is calculated. These CIs are compared with
the range of trivial misspecification, which could be (-delta, delta) or (0, delta) for nonnegative
parameters.
Value
A data frame with these variables:
1. lhs: The left-hand side variable, with respect to the operator in in the lavaan [Link]
2. op: The lavaan syntax operator: "~~" represents covariance, "=~" represents factor loading,
"~" represents regression, and "~1" represents intercept.
3. rhs: The right-hand side variable
4. group: The level of the group variable for the parameter in question
5. mi: The modification index of the fixed parameter
6. epc: The EPC if the parameter is freely estimated
7. [Link]: The target EPC that represents the minimum size of misspecification that one
would like to be detected by the test with a high power
8. [Link]: The standardized EPC if the parameter is freely estimated
9. [Link]: The standardized target expected parameter change
10. [Link]: Represents whether the modification index value is significant
11. [Link]: Represents whether the power is enough to detect the target expected parameter
change
94 miPowerFit
12. [Link]: The decision whether the parameter is misspecified or not based on Saris
et al’s method: "M" represents the parameter is misspecified, "NM" represents the parameter
is not misspecified, "EPC:M" represents the parameter is misspecified decided by checking
the expected parameter change value, "EPC:NM" represents the parameter is not misspecified
decided by checking the expected parameter change value, and "I" represents the decision is
inconclusive.
13. [Link]: The standard errors of the expected parameter changes.
14. [Link]: The lower bound of the confidence interval of expected parameter changes.
15. [Link]: The upper bound of the confidence interval of expected parameter changes.
16. [Link]: Lower confidence limit of standardized EPCs
17. [Link]: Upper confidence limit of standardized EPCs
18. [Link]: Decision whether the parameter is misspecified based on the CI method: "M"
represents the parameter is misspecified, "NM" represents the parameter is not misspecified,
and "I" represents the decision is inconclusive.
The row numbers matches with the results obtained from the inspect(object, "mi") function.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsdale, NJ:
Erlbaum.
Cohen, J. (1992). A power primer. Psychological Bulletin, 112(1), 155–159. doi:10.1037/0033-
2909.112.1.155
Saris, W. E., Satorra, A., & van der Veld, W. M. (2009). Testing structural equation models
or detection of misspecifications? Structural Equation Modeling, 16(4), 561–582. doi:10.1080/
10705510903203433
van der Veld, W. M., Saris, W. E., & Satorra, A. (2008). JRule 3.0 Users Guide. doi:10.13140/
RG.2.2.13609.90729
See Also
moreFitIndices For the additional fit indices information
Examples
library(lavaan)
# regressions
dem60 ~ ind60
dem65 ~ ind60 + dem60
# residual correlations
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
fit2 <- sem(model, data = PoliticalDemocracy, meanstructure = TRUE)
miPowerFit(fit2, stdLoad = 0.3, cor = 0.2, stdBeta = 0.2, intcept = 0.5)
Description
Modification indices (1-df Lagrange multiplier tests) from a latent variable model fitted to multiple
imputed data sets. Statistics for releasing one or more fixed or constrained parameters in model can
be calculated by pooling the gradient and information matrices across imputed data sets in a method
proposed by Mansolf, Jorgensen, & Enders (2020)—analogous to the "D1" Wald test proposed by
Li, Meng, Raghunathan, & Rubin (1991)—or by pooling the complete-data score-test statistics
across imputed data sets (i.e., "D2"; Li et al., 1991).
Usage
Arguments
object An object of class [Link]
test character indicating which pooling method to use. "D1" requests Mansolf,
Jorgensen, & Enders’ (2020) proposed Wald-like test for pooling the gradient
and information, which are then used to calculate score-test statistics in the usual
manner. "D2" (default because it is less computationall intensive) requests to
pool the complete-data score-test statistics from each imputed data set, then pool
them across imputations, described by Li et al. (1991) and Enders (2010).
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Can include any of c("[Link]", "[Link]", "[Link]"), the first 2 of
which are the default setting, which excludes any imputations that did not con-
verge or for which standard errors could not be computed. The last option
("[Link]") would exclude any imputations which yielded a nonpositive defi-
nite covariance matrix for observed or latent variables, which would include any
"improper solutions" such as Heywood cases. Specific imputation numbers can
also be included in this argument, in case users want to apply their own cus-
tom omission criteria (or simulations can use different numbers of imputations
without redundantly refitting the model).
standardized logical. If TRUE, two extra columns ($[Link] and $[Link]) will contain
standardized values for the EPCs. In the first column ($[Link]), standardiziza-
tion is based on the variances of the (continuous) latent variables. In the second
column ($[Link]), standardization is based on both the variances of both
(continuous) observed and latent variables. (Residual) covariances are standard-
ized using (residual) variances.
[Link] logical. TRUE if test == "D2". If TRUE (default), the (residual) observed co-
variances are scaled by the square-root of the diagonal elements of the Θ matrix,
and the (residual) latent covariances are scaled by the square-root of the diago-
nal elements of the Ψ matrix. If FALSE, the (residual) observed covariances are
scaled by the square-root of the diagonal elements of the model-implied covari-
ance matrix of observed variables (Σ), and the (residual) latent covariances are
scaled by the square-root of the diagonal elements of the model-implied covari-
ance matrix of the latent variables.
information character indicating the type of information matrix to use (check lavInspect
for available options). "expected" information is the default, which provides
better control of Type I errors.
power logical. If TRUE, the (post-hoc) power is computed for each modification index,
using the values of delta and alpha.
delta The value of the effect size, as used in the post-hoc power computation, currently
using the unstandardized metric of the $epc column.
alpha The significance level used for deciding if the modification index is statistically
significant or not.
[Link] If the computed power is higher than this cutoff value, the power is considered
’high’. If not, the power is considered ’low’. This affects the values in the
$decision column in the output.
sort. logical. If TRUE, sort the output using the values of the modification index
values. Higher values appear first.
[Link] 97
[Link] numeric. Filter output and only show rows with a modification index value
equal or higher than this minimum value.
[Link] integer. Filter output and only show the first maximum number rows. Most
useful when combined with the sort. option.
[Link] logical. If TRUE (default), filter output by removing all rows with NA values for
the modification indices.
op character string. Filter the output by selecting only those rows with operator
op.
Value
A [Link] containing modification indices and (S)EPCs.
Note
When test = "D2", each (S)EPC will be pooled by taking its average across imputations. When
test = "D1", EPCs will be calculated in the standard way using the pooled gradient and infor-
mation, and SEPCs will be calculated by standardizing the EPCs using model-implied (residual)
variances.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Adapted from lavaan source code, written by Yves Rosseel (Ghent University; <[Link]@[Link]>)
test = "D1" method proposed by Maxwell Mansolf (University of California, Los Angeles; <mamansolf@[Link]>)
References
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Li, K.-H., Meng, X.-L., Raghunathan, T. E., & Rubin, D. B. (1991). Significance levels from
repeated p-values with multiply-imputed [Link] Sinica, 1(1), 65–92. Retrieved from https:
//[Link]/stable/24303994
Mansolf, M., Jorgensen, T. D., & Enders, C. K. (2020). A multiple imputation score test for model
modification in structural equation models. Psychological Methods, 25(4), 393–411. doi:10.1037/
met0000243
Examples
## Not run:
## impose missing data for example
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
[Link](12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
library(Amelia)
[Link](12345)
[Link] <- amelia(HSMiss, m = 20, noms = "school", p2s = FALSE)
imps <- [Link]$imputations
## End(Not run)
Description
Robust confidence intervals for functions of parameter estimates, based on empirical sampling dis-
tributions of estimated model parameters.
Usage
monteCarloCI(object = NULL, expr, coefs, ACM, nRep = 20000,
standardized = FALSE, fast = TRUE, level = 0.95, [Link] = TRUE,
[Link] = FALSE, plot = FALSE,
ask = getOption("[Link]"), ...)
Arguments
object A object of class lavaan in which functions of parameters have already been
defined using the := operator in lavaan’s [Link]. When NULL, users
must specify expr, coefs, and ACM.
expr Optional character vector specifying functions of model parameters (e.g., an
indirect effect). Ideally, the vector should have names, which is necessary if
any user-defined parameters refer to other user-defined parameters defined ear-
lier in the vector (order matters!). All parameters appearing in the vector must
be provided in coefs, or defined (as functions of coefs) earlier in expr. If
length(expr) > 1L, nRep samples will be drawn simultaneously from a single
multivariate distribution; thus, ACM must include all parameters in coefs.
monteCarloCI 99
coefs numeric vector of parameter estimates used in expr. Ignored when object is
used.
ACM Symmetric matrix representing the asymptotic sampling covariance matrix (ACOV)
of the parameter estimates in coefs. Ignored when object is used. Information
on how to obtain the ACOV in popular SEM software is described in Details.
nRep integer. The number of samples to draw, to obtain an empirical sampling
distribution of model parameters. Many thousand are recommended to minimize
Monte Carlo error of the estimated CIs.
standardized logical indicating whether to obtain CIs for the fully standardized ("[Link]")
estimates, using their asymptotic sampling covariance matrix. Only valid when
object is of class lavaan, not [Link].
fast logical indicating whether to use a fast algorithm that assumes all functions
of parameters (in object or expr) use standard operations. Set to FALSE if
using (e.g.) c() to concatenate parameters in the definition, which would have
unintended consequences when vectorizing functions in expr across sampled
parameters.
level numeric confidence level, between 0–1
[Link] logical passed to quantile
[Link] logical indicating whether to return the simulated empirical sampling distribu-
tion of parameters (in coefs) and functions (in expr) in a list with the results.
This could be useful to calculate more precise highest-density intervals (see ex-
amples).
plot logical indicating whether to plot the empirical sampling distribution of each
function in expr
ask whether to prompt user before printing each plot
... arguments passed to hist when plot = TRUE.
Details
This function implements the Monte Carlo method of obtaining an empirical sampling distriution
of estimated model parameters, as described by MacKinnon et al. (2004) for testing indirect effects
in mediation models. The easiest way to use the function is to fit a SEM to data with lavaan,
using the := operator in the [Link] to specify user-defined parameters. All information is
then available in the resulting lavaan object. Alternatively (especially when using external SEM
software to fit the model), the expression(s) can be explicitly passed to the function, along with the
vector of estimated model parameters and their associated asymptotic sampling covariance matrix
(ACOV). For further information on the Monte Carlo method, see MacKinnon et al. (2004) and
Preacher & Selig (2012).
The asymptotic covariance matrix can be obtained easily from many popular SEM software pack-
ages.
• LISREL: Including the EC option on the OU line will print the ACM to a seperate file. The
file contains the lower triangular elements of the ACM in free format and scientific notation
• Mplus Include the command TECH3; in the OUTPUT section. The ACM will be printed in
the output.
• lavaan: Use the vcov method on the fitted lavaan object to return the ACM.
100 monteCarloCI
Value
A [Link] (to use lavaan’s print method) with point estimates and confidence limits
of each requested function of parameters in expr is returned. If [Link] = TRUE, output
will be a list with the same $Results along with a second [Link] with the $Samples (in
rows) of each parameter (in columns), and an additional column for each requested function of
those parameters.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect
effect: Distribution of the product and resampling methods. Multivariate Behavioral Research,
39(1) 99–128. doi:10.1207/s15327906mbr3901_4
Preacher, K. J., & Selig, J. P. (2010, July). Monte Carlo method for assessing multilevel mediation:
An interactive tool for creating confidence intervals for indirect effects in 1-1-1 multilevel models
[Computer software]. Available from [Link]
Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect
effects. Communication Methods and Measures, 6(2), 77–98. doi:10.1080/19312458.2012.679848
Selig, J. P., & Preacher, K. J. (2008, June). Monte Carlo method for assessing mediation: An
interactive tool for creating confidence intervals for indirect effects [Computer software]. Available
from [Link]
Examples
[Link](1234)
X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
dat <- [Link](X = X, Y = Y, M = M)
mod <- ' # direct effect
Y ~ c*X
# mediator
M ~ a*X
Y ~ b*M
# indirect effect (a*b)
ind := a*b
# total effect
total := ind + c
'
fit <- sem(mod, data = dat)
summary(fit, ci = TRUE) # print delta-method CIs
[Link](1234)
monteCarloCI(fit) # CIs more robust than delta method in smaller samples
## End(Not run)
Description
Calculate more fit indices that are not already provided in lavaan.
Usage
Arguments
object The lavaan model object provided after running the cfa, sem, growth, or lavaan
functions.
[Link] Additional fit measures to be calculated. All additional fit measures are calcu-
lated by default
nPrior The sample size on which prior is based. This argument is used to compute
[Link].
102 moreFitIndices
Details
See nullRMSEA for the further details of the computation of RMSEA of the null model.
Gamma-Hat (gammaHat; West, Taylor, & Wu, 2012) is a global goodness-of-fit index which can be
computed (assuming equal number of indicators across groups) by
p
Γ̂ = χ2k −dfk
,
p+2× N
where p is the number of variables in the model, χ2k is the χ2 test statistic value of the target model,
dfk is the degree of freedom when fitting the target model, and N is the sample size (or sample size
minus the number of groups if mimic is set to "EQS").
Adjusted Gamma-Hat (adjGammaHat; West, Taylor, & Wu, 2012) is a global fit index which can be
computed by
K × p × (p + 1)
Γ̂adj = 1− × 1 − Γ̂ ,
2 × dfk
where K is the number of groups (please refer to Dudgeon, 2004, for the multiple-group adjustment
for adjGammaHat).
The remaining indices are information criteria calculated using the object’s −2× log-likelihood,
abbreviated −2LL.
Corrected Akaike Information Criterion ([Link]; Burnham & Anderson, 2003) is a corrected
version of AIC for small sample size, often abbreviated AICc:
2q(q + 1)
AICsmall−N = AIC + ,
N −q−1
where AIC is the original AIC: −2LL + 2q (where q = the number of estimated parameters in
the target model). Note that AICc is a small-sample correction derived for univariate regression
models, so it is probably not appropriate for comparing SEMs.
Corrected Bayesian Information Criterion ([Link]; Kuha, 2004) is similar to BIC but explic-
itly specifying the sample size on which the prior is based (Nprior ) using the nPrior argument.
N
BICprior−N = −2LL + q log (1 + ).
Nprior
Bollen et al. (2014) discussed additional BICs that incorporate more terms from a Taylor series
expansion, which the standard BIC drops. The "Scaled Unit-Information Prior" BIC is calculated
depending on whether the product of the vector of estimated model parameters (θ̂) and the observed
information matrix (FIM) exceeds the number of estimated model parameters (Case 1) or not (Case
2), which is checked internally:
q
SPBICCase 1 = −2LL + q(1 − ), or
θ̂0 FIMθ̂
0
SPBICCase 2 = −2LL + θ̂ FIMθ̂,
moreFitIndices 103
Stochastic information criterion (SIC; see Preacher, 2006, for details) is similar to IBIC but does
not subtract the term q log 2 × π that is also in HBIC. SIC and IBIC account for model complexity
in a model’s functional form, not merely the number of free parameters. The SIC can be computed
by
where the inverse of FIM is the asymptotic sampling covariance matrix (ACOV).
Hannan–Quinn Information Criterion (HQC; Hannan & Quinn, 1979) is used for model selection,
similar to AIC or BIC.
Note that if Satorra–Bentler’s or Yuan–Bentler’s method is used, the fit indices using the scaled χ2
values are also provided.
Value
A numeric [Link] including any of the following requested via [Link]=
1. gammaHat: Gamma-Hat
2. adjGammaHat: Adjusted Gamma-Hat
3. [Link]: RMSEA of the default baseline (i.e., independence) model
4. [Link]: Gamma-Hat using scaled χ2
5. [Link]: Adjusted Gamma-Hat using scaled χ2
6. [Link]: RMSEA of the default baseline (i.e., independence) model using
scaled χ2
7. [Link]: Corrected (for small sample size) AIC
8. [Link]: BIC with specified prior sample size
9. spbic: Scaled Unit-Information Prior BIC (SPBIC)
10. hbic: Haughton’s BIC (HBIC)
11. ibic: Information-matrix-based BIC (IBIC)
12. sic: Stochastic Information Criterion (SIC)
13. hqc: Hannan-Quinn Information Criterion (HQC)
104 moreFitIndices
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Aaron Boulton (University of Delaware)
Ruben Arslan (Humboldt-University of Berlin, <rubenarslan@[Link]>)
Yves Rosseel (Ghent University; <[Link]@[Link]>)
References
Bollen, K. A., Ray, S., Zavisca, J., & Harden, J. J. (2012). A comparison of Bayes factor approx-
imation methods including two new methods. Sociological Methods & Research, 41(2), 294–324.
doi:10.1177/0049124112452393
Burnham, K., & Anderson, D. (2003). Model selection and multimodel inference: A practical–
theoretic approach. New York, NY: Springer–Verlag.
Dudgeon, P. (2004). A note on extending Steiger’s (1998) multiple sample RMSEA adjustment
to other noncentrality parameter-based statistic. Structural Equation Modeling, 11(3), 305–319.
doi:10.1207/s15328007sem1103_1
Kuha, J. (2004). AIC and BIC: Comparisons of assumptions and performance. Sociological Meth-
ods Research, 33(2), 188–229. doi:10.1177/0049124103262065
Preacher, K. J. (2006). Quantifying parsimony in structural equation modeling. Multivariate Be-
havioral Research, 43(3), 227-259. doi:10.1207/s15327906mbr4103_1
West, S. G., Taylor, A. B., & Wu, W. (2012). Model fit and model selection in structural equation
modeling. In R. H. Hoyle (Ed.), Handbook of structural equation modeling (pp. 209–231). New
York, NY: Guilford.
See Also
• miPowerFit For the modification indices and their power approach for model fit evaluation
• nullRMSEA For RMSEA of the default independence model
Examples
mvrnonnorm Generate Non-normal Data using Vale and Maurelli (1983) method
Description
Generate Non-normal Data using Vale and Maurelli (1983) method. The function is designed to be
as similar as the popular mvrnorm function in the MASS package. The codes are copied from mvrnorm
function in the MASS package for argument checking and lavaan package for data generation using
Vale and Maurelli (1983) method.
Usage
Arguments
n Sample size
mu A mean vector. If elements are named, those will be used as variable names in
the returned data matrix.
Sigma A positive-definite symmetric matrix specifying the covariance matrix of the
variables. If rows or columns are named (and mu is unnamed), those will be
used as variable names in the returned data matrix.
skewness A vector of skewness of the variables
kurtosis A vector of excessive kurtosis of the variables
empirical If TRUE, mu and Sigma specify the empirical rather than population mean and
covariance matrix
Value
A data matrix
Author(s)
The original function is the simulateData function written by Yves Rosseel in the lavaan package.
The function is adjusted for a convenient usage by Sunthud Pornprasertmanit (<psunthud@[Link]>).
Terrence D. Jorgensen added the feature to retain variable names from mu or Sigma.
References
Examples
[Link](123)
mvrnonnorm(20, c(1, 2), matrix(c(10, 2, 2, 5), 2, 2),
skewness = c(5, 2), kurtosis = c(3, 3))
## again, with variable names specified in mu
[Link](123)
mvrnonnorm(20, c(a = 1, b = 2), matrix(c(10, 2, 2, 5), 2, 2),
skewness = c(5, 2), kurtosis = c(3, 3))
Description
This test examines whether pairs of SEMs are nested or equivalent.
Usage
net(..., crit = 1e-04)
Arguments
... The lavaan objects used for test of nesting and equivalence
crit The upper-bound criterion for testing the equivalence of models. Models are
considered nested (or equivalent) if the difference between their χ2 fit statistics
is less than this criterion.
Details
The concept of nesting/equivalence should be the same regardless of estimation method. How-
ever, the particular method of testing nesting/equivalence (as described in Bentler & Satorra, 2010)
employed by the net function analyzes summary statistics (model-implied means and covariance
matrices, not raw data). In the case of robust methods like MLR, the raw data is only utilized for the
robust adjustment to SE and chi-sq, and the net function only checks the unadjusted chi-sq for the
purposes of testing nesting/equivalence. This method also applies to models for categorical data,
following the procedure described by Asparouhov & Muthen (2019).
Value
The Net object representing the outputs for nesting and equivalent testing, including a logical matrix
of test results and a vector of degrees of freedom for each model.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
Net-class 107
References
Bentler, P. M., & Satorra, A. (2010). Testing model nesting and equivalence. Psychological Meth-
ods, 15(2), 111–123. doi:10.1037/a0019625
Asparouhov, T., & Muthen, B. (2019). Nesting and equivalence testing for structural equation
models. Structural Equation Modeling, 26(2), 302–309. doi:10.1080/10705511.2018.1513795
Examples
## Not run:
m1 <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
m2 <- ' f1 =~ x1 + x2 + x3 + x4
f2 =~ x5 + x6 + x7 + x8 + x9 '
## End(Not run)
Description
This class contains the results of nesting and equivalence testing among multiple models
Usage
## S4 method for signature 'Net'
show(object)
Arguments
object An object of class Net.
Value
show signature(object = "Net"): prints the logical matrix of test results. NA indi-
cates a model did not converge.
summary signature(object = "Net"): prints a narrative description of results. The
original object is invisibly returned.
Slots
test Logical matrix indicating nesting/equivalence among models
df The degrees of freedom of tested models
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
See Also
net
Examples
Description
Calculate the RMSEA of the null (baseline) model
Usage
nullRMSEA(object, scaled = FALSE, silent = FALSE)
nullRMSEA 109
Arguments
object The lavaan model object provided after running the cfa, sem, growth, or lavaan
functions.
scaled If TRUE, the scaled (or robust, if available) RMSEA is returned. Ignored if a
robust test statistic was not requested.
silent If TRUE, do not print anything on the screen.
Details
RMSEA of the null model is calculated similar to the formula provided in the lavaan package. The
standard formula of RMSEA is
s
χ2 1 √
RM SEA = − × G
N × df N
where χ2 is the chi-square test statistic value of the target model, N is the total sample size, df is
the degree of freedom of the hypothesized model, G is the number of groups. Kenny proposed in
his website that
"A reasonable rule of thumb is to examine the RMSEA for the null model and make sure that is no
smaller than 0.158. An RMSEA for the model of 0.05 and a TLI of .90, implies that the RMSEA
of the null model is 0.158. If the RMSEA for the null model is less than 0.158, an incremental
measure of fit may not be that informative."
See also [Link]
Value
Author(s)
References
Kenny, D. A., Kaniskan, B., & McCoach, D. B. (2015). The performance of RMSEA in models
with small degrees of freedom. Sociological Methods Research, 44(3), 486–507. doi:10.1177/
0049124114543236
See Also
• miPowerFit For the modification indices and their power approach for model fit evaluation
• moreFitIndices For other fit indices
110 orthRotate
Examples
Description
These functions will implement orthogonal or oblique rotation on standardized factor loadings from
a lavaan output.
Usage
orthRotate(object, method = "varimax", ...)
Arguments
object A lavaan output
method The method of rotations, such as "varimax", "quartimax", "geomin", "oblimin",
or any gradient projection algorithms listed in the GPA function in the GPArotation
package.
... Additional arguments for the GPForth function (for orthRotate), the GPFoblq
function (for oblqRotate), or the function that users provide in the fun argu-
ment.
fun The name of the function that users wish to rotate the standardized solution.
The functions must take the first argument as the standardized loading matrix
and return the GPArotation object. Check this page for available functions:
rotations.
Details
These functions will rotate the unrotated standardized factor loadings by orthogonal rotation us-
ing the GPForth function or oblique rotation using the GPFoblq function the GPArotation pack-
age. The resulting rotation matrix will be used to calculate standard errors of the rotated stan-
dardized factor loading by delta method by numerically computing the Jacobian matrix by the
lav_func_jacobian_simple function.
parcelAllocation 111
Value
An linkS4class{EFA} object that saves the rotated EFA solution
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Examples
## Not run:
# Orthogonal varimax
[Link] <- orthRotate(unrotated, method = "varimax")
summary([Link], sort = FALSE, suppress = 0.3)
# Orthogonal Quartimin
orthRotate(unrotated, method = "quartimin")
# Oblique Quartimin
oblqRotate(unrotated, method = "quartimin")
# Geomin
oblqRotate(unrotated, method = "geomin")
# Target rotation
library(GPArotation)
target <- matrix(0, 9, 3)
target[1:3, 1] <- NA
target[4:6, 2] <- NA
target[7:9, 3] <- NA
colnames(target) <- c("factor1", "factor2", "factor3")
## This function works with GPArotation version 2012.3-1
funRotate(unrotated, fun = "targetQ", Target = target)
## End(Not run)
Description
This function generates a given number of randomly generated item-to-parcel allocations, fits a
model to each allocation, and provides averaged results over all allocations.
112 parcelAllocation
Usage
parcelAllocation(model, data, [Link], [Link], nAlloc = 100,
fun = "sem", alpha = 0.05, [Link] = c("chisq", "df", "cfi",
"tli", "rmsea", "srmr"), ..., [Link] = FALSE, iseed = 12345,
[Link] = TRUE, [Link] = FALSE, warn = FALSE)
Arguments
model lavaan model syntax specifying the model fit to (at least some) parceled data.
Note that there can be a mixture of items and parcels (even within the same
factor), in case certain items should never be parceled. Can be a character string
or parameter table. Also see lavaanify for more details.
data A [Link] containing all observed variables appearing in the model, as well
as those in the [Link] used to create parcels. If the data have missing val-
ues, multiple imputation before parceling is recommended: submit a stacked
data set (with a variable for the imputation number, so they can be separateed
later) and set [Link] = FALSE to return the list of [Link] (one per alloca-
tion), each of which is a stacked, imputed data set with parcels.
[Link] character vector containing names of all parcels appearing as indicators in
model.
[Link] lavaan model syntax specifying the model that would be fit to all of the un-
parceled items, including items that should be randomly allocated to parcels
appearing in model.
nAlloc The number of random items-to-parcels allocations to generate.
fun character string indicating the name of the lavaan function used to fit model
to data. Can only take the values "lavaan", "sem", "cfa", or "growth".
alpha Alpha level used as criterion for significance.
[Link] character vector containing names of fit measures to request from each fitted
lavaan model. See the output of fitMeasures for a list of available measures.
... Additional arguments to be passed to lavaanList. See also lavOptions
[Link] If TRUE, show a txtProgressBar indicating how fast the model-fitting iterates
over allocations.
iseed (Optional) Random seed used for parceling items. When the same random seed
is specified and the program is re-run, the same allocations will be generated.
Using the same iseed argument will ensure the any model is fit to the same
parcel allocations. Note: When using parallel options, you must first type
RNGkind("L'Ecuyer-CMRG") into the R Console, so that the seed will be con-
trolled across cores.
[Link] If TRUE (default), the model is fitted to each parceled data set, and the summary
of results is returned (see the Value section below). If FALSE, the items are
randomly parceled, but the model is not fit; instead, the list of [Link] is
returned (so assign it to an object).
[Link] If TRUE, a lavaanList object is returned with the list of results across alloca-
tions
warn Whether to print warnings when fitting model to each allocation
parcelAllocation 113
Details
This function implements the random item-to-parcel allocation procedure described in Sterba (2011)
and Sterba and MacCallum (2010). The function takes a single data set with item-level data, ran-
domly assigns items to parcels, fits a structural equation model to the parceled data (using lavaan-
List), and repeats this process for a user-specified number of random allocations. Results from all
fitted models are summarized in the output. For further details on the benefits of randomly allocat-
ing items to parcels, see Sterba (2011) and Sterba and MccCallum (2010).
Value
Author(s)
References
See Also
PAVranking for comparing 2 models, poolMAlloc for choosing the number of allocations
114 parcelAllocation
Examples
## 3-indicator parcels
[Link] <- '
f1 =~ par1 + par2 + par3
f2 =~ par4 + par5 + par6
'
## names of parcels
([Link] <- paste0("par", 1:6))
## Not run:
## override default random-number generator to use parallel options
RNGkind("L'Ecuyer-CMRG")
## End(Not run)
## multigroup example
simParcel$group <- 0:1 # arbitrary groups for example
[Link] <- '
f1 =~ par1 + c(L2, L2)*par2 + par3
partialInvariance 115
Description
This test will provide partial invariance testing by (a) freeing a parameter one-by-one from nested
model and compare with the original nested model or (b) fixing (or constraining) a parameter one-
by-one from the parent model and compare with the original parent model. This function only
works with congeneric models. The partialInvariance is used for continuous variable. The
partialInvarianceCat is used for categorical variables.
Usage
partialInvariance(fit, type, free = NULL, fix = NULL, refgroup = 1,
116 partialInvariance
Arguments
fit A list of models for invariance testing. Each model should be assigned by
appropriate names (see details). The result from measurementInvariance or
measurementInvarianceCat could be used in this argument directly.
type The types of invariance testing: "metric", "scalar", "strict", or "means"
free A vector of variable names that are free across groups in advance. If partial
mean invariance is tested, this argument represents a vector of factor names that
are free across groups.
fix A vector of variable names that are constrained to be equal across groups in
advance. If partial mean invariance is tested, this argument represents a vector
of factor names that are fixed across groups.
refgroup The reference group used to make the effect size comparison with the other
groups.
poolvar If TRUE, the variances are pooled across group for standardization. Otherwise,
the variances of the reference group are used for standardization.
[Link] The method used to adjust p values. See [Link] for the options for adjusting
p values. The default is to not use any corrections.
fbound The z-scores of factor that is used to calculate the effect size of the loading
difference proposed by Millsap and Olivera-Aguilar (2012).
[Link] Return the submodels fitted by this function
method The method used to calculate likelihood ratio test. See lavTestLRT for available
options
Details
There are four types of partial invariance testing:
• Partial weak invariance. The model named ’[Link]’ from the list of models is compared
with the model named ’[Link]’. Each loading will be freed or fixed from the metric and
configural invariance models respectively. The modified models are compared with the origi-
nal model. Note that the objects in the list of models must have the names of "[Link]"
and "[Link]". Users may use "metric", "weak", "loading", or "loadings" in the type ar-
gument. Note that, for testing invariance on marker variables, other variables will be assigned
as marker variables automatically.
• Partial strong invariance. The model named ’[Link]’ from the list of models is compared
with the model named either ’[Link]’ or ’[Link]’. Each intercept will be freed
or fixed from the scalar and metric invariance models respectively. The modified models are
compared with the original model. Note that the objects in the list of models must have the
partialInvariance 117
names of "[Link]" and either "[Link]" or "[Link]". Users may use "scalar",
"strong", "intercept", "intercepts", "threshold", or "thresholds" in the type argument. Note
that, for testing invariance on marker variables, other variables will be assigned as marker
variables automatically. Note that if all variables are dichotomous, scalar invariance testing is
not available.
• Partial strict invariance. The model named either ’[Link]’ or ’[Link]’ (or ’[Link]’)
from the list of models is compared with the model named ’[Link]’. Each residual vari-
ance will be freed or fixed from the strict and scalar (or metric) invariance models respectively.
The modified models are compared with the original model. Note that the objects in the list
of models must have the names of "[Link]" and either "[Link]", "[Link]", or
"[Link]". Users may use "strict", "residual", "residuals", "error", or "errors" in the type
argument.
• Partial mean invariance. The model named either ’[Link]’ or ’[Link]’ (or ’[Link]’
or ’[Link]’) from the list of models is compared with the model named ’[Link]’. Each
factor mean will be freed or fixed from the means and scalar (or strict or metric) invariance
models respectively. The modified models are compared with the original model. Note that
the objects in the list of models must have the names of "[Link]" and either "[Link]",
"[Link]", "[Link]", or "[Link]". Users may use "means" or "mean" in the
type argument.
Value
A list of results are provided. The list will consists of at least two elements:
1. estimates: The results of parameter estimates including pooled estimates (poolest), the es-
timates for each group, standardized estimates for each group (std), the difference in standard-
ized values, and the effect size statistic (q for factor loading difference and h for error variance
118 partialInvariance
difference). See the details of this effect size statistic by running vignette("partialInvariance").
In the partialInvariance function, the additional effect statistics proposed by Millsap and
Olivera-Aguilar (2012) are provided. For factor loading, the additional outputs are the ob-
served mean difference (diff_mean), the mean difference if factor scores are low (low_fscore),
and the mean difference if factor scores are high (high_fscore). The low factor score is cal-
culated by (a) finding the factor scores that its z score equals -bound (the default is −2) from
all groups and (b) picking the minimum value among the factor scores. The high factor score
is calculated by (a) finding the factor scores that its z score equals bound (default = 2) from
all groups and (b) picking the maximum value among the factor scores. For measurement
intercepts, the additional outputs are the observed means difference (diff_mean) and the pro-
portion of the differences in the intercepts over the observed means differences (propdiff).
For error variances, the additional outputs are the proportion of the difference in error vari-
ances over the difference in observed variances (propdiff).
2. results: Statistical tests as well as the change in CFI are provided. χ2 and p value are
provided for all methods.
3. models: The submodels used in the free and fix methods, as well as the nested and parent
models. The nested and parent models will be changed from the original models if free or
fit arguments are specified.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
Millsap, R. E., & Olivera-Aguilar, M. (2012). Investigating measurement invariance using con-
firmatory factor analysis. In R. H. Hoyle (Ed.), Handbook of structural equation modeling (pp.
380–392). New York, NY: Guilford.
See Also
measurementInvariance for measurement invariance for continuous variables; measurementInvarianceCat
for measurement invariance for categorical variables; lavTestWald for multivariate Wald test
Examples
library(lavaan)
f1 =~ NA*x1 + x2 + x3
f2 =~ NA*x4 + x5 + x6
f1 ~~ c(1, NA)*f1
f2 ~~ c(1, NA)*f2
"
## Not run:
partialInvariance(models, "metric", free = "x5") # "x5" is free across groups in advance
partialInvariance(models, "metric", fix = "x4") # "x4" is fixed across groups in advance
f <- rnorm(1000, 0, 1)
u1 <- 0.9*f + rnorm(1000, 1, sqrt(0.19))
u2 <- 0.8*f + rnorm(1000, 1, sqrt(0.36))
u3 <- 0.6*f + rnorm(1000, 1, sqrt(0.64))
u4 <- 0.7*f + rnorm(1000, 1, sqrt(0.51))
u1 <- [Link](cut(u1, breaks = c(-Inf, 0, Inf)))
u2 <- [Link](cut(u2, breaks = c(-Inf, 0.5, Inf)))
u3 <- [Link](cut(u3, breaks = c(-Inf, 0, Inf)))
u4 <- [Link](cut(u4, breaks = c(-Inf, -0.5, Inf)))
g <- rep(c(1, 2), 500)
dat2 <- [Link](u1, u2, u3, u4, g)
## End(Not run)
Description
This function quantifies and assesses the consequences of parcel-allocation variability for model
ranking of structural equation models (SEMs) that differ in their structural specification but share
the same parcel-level measurement specification (see Sterba & Rights, 2016). This function calls
parcelAllocation—which can be used with only one SEM in isolation—to fit two (assumed)
PAVranking 121
nested models to each of a specified number of random item-to-parcel allocations. Output includes
summary information about the distribution of model selection results (including plots) and the
distribution of results for each model individually, across allocations within-sample. Note that this
function can be used when selecting among more than two competing structural models as well (see
instructions below involving the seed argument).
Usage
PAVranking(model0, model1, data, [Link], [Link], nAlloc = 100,
fun = "sem", alpha = 0.05, [Link] = 10, [Link] = c("chisq",
"df", "cfi", "tli", "rmsea", "srmr", "logl", "aic", "bic", "bic2"), ...,
[Link] = FALSE, iseed = 12345, warn = FALSE)
Arguments
model0, model1 lavaan model syntax specifying nested models (model0 within model1) to be
fitted to the same parceled data. Note that there can be a mixture of items and
parcels (even within the same factor), in case certain items should never be
parceled. Can be a character string or parameter table. Also see lavaanify
for more details.
data A [Link] containing all observed variables appearing in the model, as well
as those in the [Link] used to create parcels. If the data have missing val-
ues, multiple imputation before parceling is recommended: submit a stacked
data set (with a variable for the imputation number, so they can be separateed
later) and set [Link] = FALSE to return the list of [Link] (one per alloca-
tion), each of which is a stacked, imputed data set with parcels.
[Link] character vector containing names of all parcels appearing as indicators in
model.
[Link] lavaan model syntax specifying the model that would be fit to all of the un-
parceled items, including items that should be randomly allocated to parcels
appearing in model.
nAlloc The number of random items-to-parcels allocations to generate.
fun character string indicating the name of the lavaan function used to fit model
to data. Can only take the values "lavaan", "sem", "cfa", or "growth".
alpha Alpha level used as criterion for significance.
[Link] Criterion for assessing evidence in favor of one model over another. See Rafferty
(1995) for guidelines (default is "very strong evidence" in favor of the model
with lower BIC).
[Link] character vector containing names of fit measures to request from each fitted
lavaan model. See the output of fitMeasures for a list of available measures.
... Additional arguments to be passed to lavaanList. See also lavOptions
[Link] If TRUE, show a txtProgressBar indicating how fast each model-fitting iterates
over allocations.
iseed (Optional) Random seed used for parceling items. When the same random
seed is specified and the program is re-run, the same allocations will be gen-
erated. The seed argument can be used to assess parcel-allocation variability
122 PAVranking
in model ranking when considering more than two models. For each pair of
models under comparison, the program should be rerun using the same random
seed. Doing so ensures that multiple model comparisons will employ the same
set of parcel datasets. Note: When using parallel options, you must first type
RNGkind("L'Ecuyer-CMRG") into the R Console, so that the seed will be con-
trolled across cores.
warn Whether to print warnings when fitting models to each allocation
Details
This is based on a SAS macro ParcelAlloc (Sterba & MacCallum, 2010). The PAVranking func-
tion produces results discussed in Sterba and Rights (2016) relevant to the assessment of parcel-
allocation variability in model selection and model ranking. Specifically, the PAVranking function
first calls parcelAllocation to generate a given number (nAlloc) of item-to-parcel allocations,
fitting both specified models to each allocation, and providing summaryies of PAV for each model.
Additionally, PAVranking provides the following new summaries:
• PAV in model selection index values and model ranking between Models model0 and model1.
• The proportion of allocations that converged and the proportion of proper solutions (results
are summarized for allocations with both converged and proper allocations only).
For further details on the benefits of the random allocation of items to parcels, see Sterba (2011)
and Sterba and MacCallum (2010).
To test whether nested models have equivalent fit, results can be pooled across allocations using
the same methods available for pooling results across multiple imputations of missing data (see
Examples).
Note: This function requires the lavaan package. Missing data must be coded as NA. If the function
returns "Error in [Link]() : figure margins too large", the user may need to increase size
of the plot window (e.g., in RStudio) and rerun the function.
Value
[Link] Results returned by parcelAllocation for model0 (see the Value section).
[Link] Results returned by parcelAllocation for model1 (see the Value section).
model0.v.model1
A list of model-comparison results, including the following:
• LRT_Summary: The average likelihood ratio test across allocations, as well
as the SD, minimum, maximum, range, and the proportion of allocations
for which the test was significant.
• Fit_Index_Differences: Differences in fit indices, organized by what
proportion favored each model and among those, what the average differ-
ence was.
• Favored_by_BIC: The proportion of allocations in which each model met
the criterion ([Link]) for a substantial difference in fit.
• Convergence_Summary: The proportion of allocations in which each model
(and both models) converged on a solution.
Histograms are also printed to the current plot-output device.
PAVranking 123
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Raftery, A. E. (1995). Bayesian model selection in social research. Sociological Methodology, 25,
111–163. doi:10.2307/271063
Sterba, S. K. (2011). Implications of parcel-allocation variability for comparing fit of item-solutions
and parcel-solutions. Structural Equation Modeling, 18(4), 554–[Link].1080/10705511.2011.607073
Sterba, S. K., & MacCallum, R. C. (2010). Variability in parameter estimates and model fit
across repeated allocations of items to parcels. Multivariate Behavioral Research, 45(2), 322–358.
doi:10.1080/00273171003680302
Sterba, S. K., & Rights, J. D. (2016). Accounting for parcel-allocation variability in practice:
Combining sources of uncertainty and choosing the number of allocations. Multivariate Behavioral
Research, 51(2–3), 296–313. doi:10.1080/00273171.2016.1144502
Sterba, S. K., & Rights, J. D. (2017). Effects of parceling on model selection: Parcel-allocation
variability in model ranking. Psychological Methods, 22(1), 47–68. doi:10.1037/met0000067
See Also
parcelAllocation for fitting a single model, poolMAlloc for choosing the number of allocations
Examples
## Not run:
124 permuteMeasEq
## End(Not run)
Description
The function permuteMeasEq provides tests of hypotheses involving measurement equivalence, in
one of two frameworks: multigroup CFA or MIMIC models.
Usage
permuteMeasEq(nPermute, modelType = c("mgcfa", "mimic"), con, uncon = NULL,
null = NULL, param = NULL, freeParam = NULL, covariates = NULL,
AFIs = NULL, moreAFIs = NULL, maxSparse = 10, maxNonconv = 10,
showProgress = TRUE, warn = -1, datafun, extra,
parallelType = c("none", "multicore", "snow"), ncpus = NULL, cl = NULL,
iseed = 12345)
Arguments
nPermute An integer indicating the number of random permutations used to form empirical
distributions under the null hypothesis.
permuteMeasEq 125
the number of follow-up tests. Parameter types that are already unconstrained
across groups in the fitted con model (i.e., a partial invariance model) will
automatically be ignored, so they do not need to be specified in freeParam.
Parameter names must match those returned by names(coef(con)), but omit-
ting any group-specific suffixes (e.g., "f1~1" rather than "f1~1.g2") or user-
specified labels (that is, the parameter names must follow the rules of lavaan
[Link]).
covariates An optional character vector, only applicable when modelType = "mimic". The
observed data are partitioned into columns indicated by covariates, and the
rows are permuted simultaneously for the entire set before being merged with
the remaining data. Thus, the covariance structure is preserved among the co-
variates, which is necessary when (e.g.) multiple dummy codes are used to rep-
resent a discrete covariate or when covariates interact. If covariates = NULL
when modelType = "mimic", the value of covariates is inferred by searching
param for predictors (i.e., variables appearing after the "~" operator).
AFIs A character vector indicating which alternative fit indices (or chi-squared itself)
are to be used to test the multiparameter omnibus null hypothesis that the con-
straints specified in con hold in the population. Any fit measures returned by
fitMeasures may be specified (including constants like "df", which would be
nonsensical). If both AFIs and moreAFIs are NULL, only "chisq" will be re-
turned.
moreAFIs Optional. A character vector indicating which (if any) alternative fit indices
returned by moreFitIndices are to be used to test the multiparameter omnibus
null hypothesis that the constraints specified in con hold in the population.
maxSparse Only applicable when modelType = "mgcfa" and at least one indicator is ordered.
An integer indicating the maximum number of consecutive times that randomly
permuted group assignment can yield a sample in which at least one category (of
an ordered indicator) is unobserved in at least one group, such that the same set
of parameters cannot be estimated in each group. If such a sample occurs, group
assignment is randomly permuted again, repeatedly until a sample is obtained
with all categories observed in all groups. If maxSparse is exceeded, NA will be
returned for that iteration of the permutation distribution.
maxNonconv An integer indicating the maximum number of consecutive times that a random
permutation can yield a sample for which the model does not converge on a
solution. If such a sample occurs, permutation is attempted repeatedly until
a sample is obtained for which the model does converge. If maxNonconv is
exceeded, NA will be returned for that iteration of the permutation distribution,
and a warning will be printed when using show or summary.
showProgress Logical. Indicating whether to display a progress bar while permuting. Silently
set to FALSE when using parallel options.
warn Sets the handling of warning messages when fitting model(s) to permuted data
sets. See options.
datafun An optional function that can be applied to the data (extracted from con) af-
ter each permutation, but before fitting the model(s) to each permutation. The
datafun function must have an argument named data that accepts a [Link],
and it must return a [Link] containing the same column names. The col-
umn order may differ, the values of those columns may differ (so be careful!),
permuteMeasEq 127
and any additional columns will be ignored when fitting the model, but an er-
ror will result if any column names required by the model syntax do not appear
in the transformed data set. Although available for any modelType, datafun
may be useful when using the MIMIC method to test for nonuniform DIF (met-
ric/weak invariance) by using product indicators for a latent factor represent-
ing the interaction between a factor and one of the covariates, in which case
the product indicators would need to be recalculated after each permutation of
the covariates. To access other R objects used within permuteMeasEq, the
arguments to datafun may also contain any subset of the following: "con",
"uncon", "null", "param", "freeParam", "covariates", "AFIs", "moreAFIs",
"maxSparse", "maxNonconv", and/or "iseed". The values for those arguments
will be the same as the values supplied to permuteMeasEq.
extra An optional function that can be applied to any (or all) of the fitted lavaan ob-
jects (con, uncon, and/or null). This function will also be applied after fitting
the model(s) to each permuted data set. To access the R objects used within
permuteMeasEq, the arguments to extra must be any subset of the following:
"con", "uncon", "null", "param", "freeParam", "covariates", "AFIs", "moreAFIs",
"maxSparse", "maxNonconv", and/or "iseed". The values for those arguments
will be the same as the values supplied to permuteMeasEq. The extra function
must return a named numeric vector or a named list of scalars (i.e., a list of
numeric vectors of length == 1). Any unnamed elements (e.g., "" or NULL) of
the returned object will result in an error.
parallelType The type of parallel operation to be used (if any). The default is "none". Forking
is not possible on Windows, so if "multicore" is requested on a Windows
machine, the request will be changed to "snow" with a message.
ncpus Integer: number of processes to be used in parallel operation. If NULL (the de-
fault) and parallelType c("multicore","snow"), the default is one less than
the maximum number of processors detected by detectCores. This default is
also silently set if the user specifies more than the number of processors detected.
cl An optional parallel or snow cluster for use when parallelType = "snow". If
NULL, a "PSOCK" cluster on the local machine is created for the duration of the
permuteMeasEq call. If a valid makeCluster object is supplied, parallelType
is silently set to "snow", and ncpus is silently set to length(cl).
iseed Integer: Only used to set the states of the RNG when using parallel options, in
which case RNGkind is set to "L'Ecuyer-CMRG" with a message. See clusterSetRNGStream
and Section 6 of vignette("parallel", "parallel") for more details. If user
supplies an invalid value, iseed is silently set to the default (12345). To set the
state of the RNG when not using parallel options, call [Link] before calling
permuteMeasEq.
Details
The function permuteMeasEq provides tests of hypotheses involving measurement equivalence, in
one of two frameworks:
1. 1 For multiple-group CFA models, provide a pair of nested lavaan objects, the less constrained
of which (uncon) freely estimates a set of measurement parameters (e.g., factor loadings,
intercepts, or thresholds; specified in param) in all groups, and the more constrained of which
128 permuteMeasEq
(con) constrains those measurement parameters to equality across groups. Group assignment
is repeatedly permuted and the models are fit to each permutation, in order to produce an
empirical distribution under the null hypothesis of no group differences, both for (a) changes
in user-specified fit measures (see AFIs and moreAFIs) and for (b) the maximum modification
index among the user-specified equality constraints. Configural invariance can also be tested
by providing that fitted lavaan object to con and leaving uncon = NULL, in which case param
must be NULL as well.
2. 2 In MIMIC models, one or a set of continuous and/or discrete covariates can be permuted,
and a constrained model is fit to each permutation in order to provide a distribution of any fit
measures (namely, the maximum modification index among fixed parameters in param) under
the null hypothesis of measurement equivalence across levels of those covariates.
In either framework, modification indices for equality constraints or fixed parameters specified in
param are calculated from the constrained model (con) using the function lavTestScore.
For multiple-group CFA models, the multiparameter omnibus null hypothesis of measurement
equivalence/invariance is that there are no group differences in any measurement parameters (of
a particular type). This can be tested using the anova method on nested lavaan objects, as seen in
the output of measurementInvariance, or by inspecting the change in alternative fit indices (AFIs)
such as the CFI. The permutation randomization method employed by permuteMeasEq generates
an empirical distribution of any AFIs under the null hypothesis, so the user is not restricted to using
fixed cutoffs proposed by Cheung & Rensvold (2002), Chen (2007), or Meade, Johnson, & Braddy
(2008).
If the multiparameter omnibus null hypothesis is rejected, partial invariance can still be established
by freeing invalid equality constraints, as long as equality constraints are valid for at least two
indicators per factor. Modification indices can be calculated from the constrained model (con), but
multiple testing leads to inflation of Type I error rates. The permutation randomization method
employed by permuteMeasEq creates a distribution of the maximum modification index if the null
hypothesis is true, which allows the user to control the familywise Type I error rate in a manner
similar to Tukey’s q (studentized range) distribution for the Honestly Significant Difference (HSD)
post hoc test.
For MIMIC models, DIF can be tested by comparing modification indices of regression paths to
the permutation distribution of the maximum modification index, which controls the familywise
Type I error rate. The MIMIC approach could also be applied with multiple-group models, but
the grouping variable would not be permuted; rather, the covariates would be permuted separately
within each group to preserve between-group differences. So whether parameters are constrained
or unconstrained across groups, the MIMIC approach is only for testing null hypotheses about the
effects of covariates on indicators, controlling for common factors.
In either framework, lavaan’s [Link] argument is used to preserve the order of groups seen
in con when permuting the data.
Value
The permuteMeasEq object representing the results of testing measurement equivalence (the mul-
tiparameter omnibus test) and DIF (modification indices), as well as diagnostics and any extra
output.
permuteMeasEq 129
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Papers about permutation tests of measurement equivalence:
Jorgensen, T. D., Kite, B. A., Chen, P.-Y., & Short, S. D. (2018). Permutation randomization meth-
ods for testing measurement equivalence and detecting differential item functioning in multiple-
group confirmatory factor analysis. Psychological Methods, 23(4), 708–728. doi:10.1037/met0000152
Kite, B. A., Jorgensen, T. D., & Chen, P.-Y. (2018). Random permutation testing applied to
measurement invariance testing with ordered-categorical indicators. Structural Equation Model-
ing 25(4), 573–587. doi:10.1080/10705511.2017.1421467
Jorgensen, T. D. (2017). Applying permutation tests and multivariate modification indices to con-
figurally invariant models that need respecification. Frontiers in Psychology, 8(1455). doi:10.3389/
fpsyg.2017.01455
Additional reading:
Chen, F. F. (2007). Sensitivity of goodness of fit indexes to lack of measurement invariance. Struc-
tural Equation Modeling, 14(3), 464–504. doi:10.1080/10705510701301834
Cheung, G. W., & Rensvold, R. B. (2002). Evaluating goodness-of-fit indexes for testing measure-
ment invariance. Structural Equation Modeling, 9(2), 233–255. doi:10.1207/S15328007SEM0902_5
Meade, A. W., Johnson, E. C., & Braddy, P. W. (2008). Power and sensitivity of alternative
fit indices in tests of measurement invariance. Journal of Applied Psychology, 93(3), 568–592.
doi:10.1037/00219010.93.3.568
Widamin, K. F., & Thompson, J. S. (2003). On specifying the null model for incremental fit in-
dices in structural equation modeling. Psychological Methods, 8(1), 16–37. doi:10.1037/1082-
989X.8.1.16
See Also
TukeyHSD, lavTestScore, measurementInvariance, measurementInvarianceCat
Examples
## Not run:
########################
## Multiple-Group CFA ##
########################
## specify and fit an appropriate null model for incremental fit indices
[Link] <- c(paste0("x", 1:9, " ~ c(T", 1:9, ", T", 1:9, ", T", 1:9, ")*1"),
130 permuteMeasEq
paste0("x", 1:9, " ~~ c(L", 1:9, ", L", 1:9, ", L", 1:9, ")*x", 1:9))
[Link] <- cfa([Link], data = HS, group = "ageGroup")
## observed EPC
extra([Link])
132 permuteMeasEq
###########
## MIMIC ##
###########
x1 ~~ [Link]
x2 ~~ [Link]
x3 ~~ [Link]
'
[Link](12345)
[Link] <- permuteMeasEq(nPermute = 20, modelType = "mimic",
con = [Link], param = param,
covariates = "ageyr", datafun = datafun)
summary([Link])
## End(Not run)
Description
This class contains the results of tests of Measurement Equivalence and Differential Item Function-
ing (DIF).
Usage
## S4 method for signature 'permuteMeasEq'
show(object)
Arguments
object, x object of class permuteMeasEq
alpha alpha level used to draw confidence limits in hist and flag significant statistics
in summary output
nd number of digits to display
extra logical indicating whether the summary output should return permutation-based
p values for each statistic returned by the extra function. If FALSE (default),
summary will return permutation-based p values for each modification index.
... Additional arguments to pass to hist
AFI character indicating the fit measure whose permutation distribution should be
plotted
printLegend logical. If TRUE (default), a legend will be printed with the histogram
legendArgs list of arguments passed to the legend function. The default argument is a list
placing the legend at the top-left of the figure.
134 permuteMeasEq-class
Value
• The show method prints a summary of the multiparameter omnibus test results, using the user-
specified AFIs. The parametric (∆)χ2 test is also displayed.
• The summary method prints the same information from the show method, but when extra
= FALSE (the default) it also provides a table summarizing any requested follow-up tests of
DIF using modification indices in slot [Link]. The user can also specify an alpha level for
flagging modification indices as significant, as well as nd (the number of digits displayed).
For each modification index, the p value is displayed using a central χ2 distribution with the
df shown in that column. Additionally, a p value is displayed using the permutation distri-
bution of the maximum index, which controls the familywise Type I error rate in a manner
similar to Tukey’s studentized range test. If any indices are flagged as significant using the
[Link], then a message is displayed for each flagged index. The invisibly returned
[Link] is the displayed table of modification indices, unless permuteMeasEq was called
with param = NULL, in which case the invisibly returned object is object. If extra = TRUE, the
permutation-based p values for each statistic returned by the extra function are displayed and
returned in a [Link] instead of the modification indices requested in the param argument.
• The hist method returns a list of length == 2, containing the arguments for the call to hist
and the arguments to the call for legend, respectively. This list may facilitate creating a
customized histogram of [Link], [Link], or [Link]
Slots
PT A [Link] returned by a call to parTable on the constrained model
modelType A character indicating the specified modelType in the call to permuteMeasEq
ANOVA A numeric vector indicating the results of the observed (∆)χ2 test, based on the central χ2
distribution
[Link] A vector of observed (changes in) user-selected fit measures
[Link] The permutation distribution(s) of user-selected fit measures. A [Link] with [Link]
rows and one column for each [Link].
[Link] A vector of p values (one for each element in slot [Link]) calculated using slot [Link],
indicating the probability of observing a change at least as extreme as [Link] if the null hy-
pothesis were true
[Link] A [Link] of observed Lagrange Multipliers (modification indices) associated with
the equality constraints or fixed parameters specified in the param argument. This is a subset
of the output returned by a call to lavTestScore on the constrained model.
[Link] The permutation distribution of the maximum modification index (among those seen in
slot [Link]$X2) at each permutation of group assignment or of covariates
[Link] If permuteMeasEq was called with an extra function, the output when applied to the
original data is concatenated into this vector
[Link] A [Link], each column of which contains the permutation distribution of the
corresponding statistic in slot [Link]
[Link] An integer indicating the number of permutations requested by the user
[Link] An integer indicating the number of permuation iterations which yielded a con-
verged solution
plausibleValues 135
[Link] An integer vector of length [Link] indicating how many times group
assignment was randomly permuted (at each iteration) before converging on a solution
[Link] Only relevant with ordered indicators when modelType == "mgcfa". An integer vec-
tor of length [Link] indicating how many times group assignment was randomly
permuted (at each iteration) before obtaining a sample with all categories observed in all
groups.
oldSeed An integer vector storing the value of .[Link] before running permuteMeasEq.
Only relevant when using a parallel/multicore option and the original RNGkind() != "L'Ecuyer-CMRG".
This enables users to restore their previous .[Link] state, if desired, by running: .[Link][-1]
<- permutedResults@oldSeed[-1]
Author(s)
See Also
permuteMeasEq
Examples
Description
Draw plausible values of factor scores estimated from a fitted lavaan model, then treat them as
multiple imputations of missing data using runMI.
Usage
Arguments
Details
Because latent variables are unobserved, they can be considered as missing data, which can be im-
puted using Monte Carlo methods. This may be of interest to researchers with sample sizes too small
to fit their complex structural models. Fitting a factor model as a first step, lavPredict provides
factor-score estimates, which can be treated as observed values in a path analysis (Step 2). How-
ever, the resulting standard errors and test statistics could not be trusted because the Step-2 analysis
would not take into account the uncertainty about the estimated factor scores. Using the asymptotic
sampling covariance matrix of the factor scores provided by lavPredict, plausibleValues draws
a set of nDraws imputations from the sampling distribution of each factor score, returning a list of
data sets that can be treated like multiple imputations of incomplete data. If the data were already
imputed to handle missing data, plausibleValues also accepts an object of class [Link], and
will draw nDraws plausible values from each imputation. Step 2 would then take into account
uncertainty about both missing values and factor scores. Bayesian methods can also be used to
generate factor scores, as available with the blavaan package, in which case plausible values are
simply saved parameters from the posterior distribution. See Asparouhov and Muthen (2010) for
further technical details and references.
Each returned [Link] includes a [Link] column that indicates the corresponding rows in the
data set to which the model was originally fitted (unless the user requests only Level-2 variables).
This can be used to merge the plausible values with the original observed data, but users should
note that including any new variables in a Step-2 model might not accurately account for their
relationship(s) with factor scores because they were not accounted for in the Step-1 model from
which factor scores were estimated.
If object is a multilevel lavaan model, users can request plausible values for latent variables at
particular levels of analysis by setting the lavPredict argument level=1 or level=2. If the level
argument is not passed via . . . , then both levels are returned in a single merged data set per draw.
For multilevel models, each returned [Link] also includes a column indicating to which cluster
each row belongs (unless the user requests only Level-2 variables).
plausibleValues 137
Value
A list of length nDraws, each of which is a [Link] containing plausible values, which can be
treated as a list of imputed data sets to be passed to runMI (see Examples). If object is of class
[Link], the list will be of length nDraws*m, where m is the number of imputations.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Asparouhov, T. & Muthen, B. O. (2010). Plausible values for latent variables using Mplus. Tech-
nical Report. Retrieved from [Link]/download/[Link]
See Also
runMI, [Link]
Examples
## End(Not run)
## Not run:
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
[Link](12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
## impute data
library(Amelia)
[Link](12345)
[Link] <- amelia(HSMiss, m = 10, noms = "school", p2s = FALSE)
imps <- [Link]$imputations
## specify CFA model from lavaan's ?cfa help page
[Link] <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
out2 <- [Link]([Link], data = imps)
PVs <- plausibleValues(out2, nDraws = nPVs)
plotProbe 139
## End(Not run)
Description
This function will plot the line graphs representing the simple effect of the independent variable
given the values of the moderator. For multigroup models, it will only generate a plot for 1 group,
as specified in the function used to obtain the first argument.
Usage
plotProbe(object, xlim, xlab = "Indepedent Variable",
ylab = "Dependent Variable", legend = TRUE, legendArgs = list(), ...)
Arguments
object The result of probing latent interaction obtained from probe2WayMC, probe2WayRC,
probe3WayMC, or probe3WayRC function.
xlim The vector of two numbers: the minimum and maximum values of the indepen-
dent variable
xlab The label of the x-axis
ylab The label of the y-axis
legend logical. If TRUE (default), a legend is printed.
legendArgs list of arguments passed to legend function if legend=TRUE.
... Any addition argument for the plot function
Value
None. This function will plot the simple main effect only.
140 plotProbe
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Schoemann, A. M., & Jorgensen, T. D. (2021). Testing and interpreting latent variable interactions
using the semTools package. Psych, 3(3), 322–335. doi:10.3390/psych3030024
See Also
• indProd For creating the indicator products with no centering, mean centering, double-mean
centering, or residual centering.
• probe2WayMC For probing the two-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe3WayMC For probing the three-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe2WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• probe3WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
Examples
library(lavaan)
Description
Plots the sampling distributions of RMSEA based on the noncentral chi-square distributions
Usage
plotRMSEAdist(rmsea, n, df, ptile = NULL, caption = NULL,
rmseaScale = TRUE, group = 1)
Arguments
rmsea The vector of RMSEA values to be plotted
n Sample size of a dataset
df Model degrees of freedom
ptile The percentile rank of the distribution of the first RMSEA that users wish to plot
a vertical line in the resulting graph
caption The name vector of each element of rmsea
rmseaScale If TRUE, the RMSEA scale is used in the x-axis. If FALSE, the chi-square scale
is used in the x-axis.
group The number of group that is used to calculate RMSEA.
Details
This function creates overlappling plots of the sampling distribution of RMSEA based on noncentral
χ2 distribution (MacCallum, Browne, & Suguwara, 1996). First, the noncentrality parameter (λ) is
calculated from RMSEA (Steiger, 1998; Dudgeon, 2004) by
λ = (N − 1)dε2 /K,
where N is sample size, d is the model degree of freedom, K is the number of group, and ε is
the population RMSEA. Next, the noncentral χ2 distribution with a specified df and noncentrality
parameter is plotted. Thus, the x-axis represents the sample χ2 value. The sample χ2 value can be
transformed to the sample RMSEA scale (ε̂) by
s
√ χ2 − d
ε̂ = K ,
(N − 1)d
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
plotRMSEApower 143
References
Dudgeon, P. (2004). A note on extending Steiger’s (1998) multiple sample RMSEA adjustment
to other noncentrality parameter-based statistic. Structural Equation Modeling, 11(3), 305–319.
doi:10.1207/s15328007sem1103_1
MacCallum, R. C., Browne, M. W., & Sugawara, H. M. (1996). Power analysis and determi-
nation of sample size for covariance structure modeling. Psychological Methods, 1(2), 130–149.
doi:10.1037/1082989X.1.2.130
Steiger, J. H. (1998). A note on multiple sample extensions of the RMSEA fit index. Structural
Equation Modeling, 5(4), 411–419. doi:10.1080/10705519809540115
See Also
• plotRMSEApower to plot the statistical power based on population RMSEA given the sample
size
• findRMSEApower to find the statistical power based on population RMSEA given a sample
size
• findRMSEAsamplesize to find the minium sample size for a given statistical power based on
population RMSEA
Examples
Description
Plots power of RMSEA over a range of sample sizes
Usage
plotRMSEApower(rmsea0, rmseaA, df, nlow, nhigh, steps = 1, alpha = 0.05,
group = 1, ...)
Arguments
rmsea0 Null RMSEA
rmseaA Alternative RMSEA
df Model degrees of freedom
nlow Lower sample size
nhigh Upper sample size
144 plotRMSEApower
steps Increase in sample size for each iteration. Smaller values of steps will lead to
more precise plots. However, smaller step sizes means a longer run time.
alpha Alpha level used in power calculations
group The number of group that is used to calculate RMSEA.
... The additional arguments for the plot function.
Details
This function creates plot of power for RMSEA against a range of sample sizes. The plot places
sample size on the horizontal axis and power on the vertical axis. The user should indicate the
lower and upper values for sample size and the sample size between each estimate ("step size") We
strongly urge the user to read the sources below (see References) before proceeding. A web ver-
sion of this function is available at: [Link] This func-
tion is also implemented in the web application "power4SEM": [Link]
power4SEM/
Value
Plot of power for RMSEA against a range of sample sizes
Author(s)
Alexander M. Schoemann (East Carolina University; <schoemanna@[Link]>)
Kristopher J. Preacher (Vanderbilt University; <[Link]@[Link]>)
Donna L. Coffman (Pennsylvania State University; <dlc30@[Link]>)
References
MacCallum, R. C., Browne, M. W., & Cai, L. (2006). Testing differences between nested covari-
ance structure models: Power analysis and null hypotheses. Psychological Methods, 11(1), 19–35.
doi:10.1037/1082989X.11.1.19
MacCallum, R. C., Browne, M. W., & Sugawara, H. M. (1996). Power analysis and determi-
nation of sample size for covariance structure modeling. Psychological Methods, 1(2), 130–149.
doi:10.1037/1082989X.1.2.130
MacCallum, R. C., Lee, T., & Browne, M. W. (2010). The issue of isopower in power analysis
for tests of structural equation models. Structural Equation Modeling, 17(1), 23–41. doi:10.1080/
10705510903438906
Preacher, K. J., Cai, L., & MacCallum, R. C. (2007). Alternatives to traditional model comparison
strategies for covariance structure models. In T. D. Little, J. A. Bovaird, & N. A. Card (Eds.),
Modeling contextual effects in longitudinal studies (pp. 33–62). Mahwah, NJ: Lawrence Erlbaum
Associates.
Steiger, J. H. (1998). A note on multiple sample extensions of the RMSEA fit index. Structural
Equation Modeling, 5(4), 411–419. doi:10.1080/10705519809540115
Steiger, J. H., & Lind, J. C. (1980, June). Statistically based tests for the number of factors. Paper
presented at the annual meeting of the Psychometric Society, Iowa City, IA.
plotRMSEApowernested 145
Jak, S., Jorgensen, T. D., Verdam, M. G., Oort, F. J., & Elffers, L. (2021). Analytical power cal-
culations for structural equation modeling: A tutorial and Shiny app. Behavior Research Methods,
53, 1385–1406. doi:10.3758/s13428020014790
See Also
• plotRMSEAdist to visualize the RMSEA distributions
• findRMSEApower to find the statistical power based on population RMSEA given a sample
size
• findRMSEAsamplesize to find the minium sample size for a given statistical power based on
population RMSEA
Examples
Description
Plot power of nested model RMSEA over a range of possible sample sizes.
Usage
plotRMSEApowernested(rmsea0A = NULL, rmsea0B = NULL, rmsea1A,
rmsea1B = NULL, dfA, dfB, nlow, nhigh, steps = 1, alpha = 0.05,
group = 1, ...)
Arguments
rmsea0A The H0 baseline RMSEA
rmsea0B The H0 alternative RMSEA (trivial misfit)
rmsea1A The H1 baseline RMSEA
rmsea1B The H1 alternative RMSEA (target misfit to be rejected)
dfA degree of freedom of the more-restricted model
dfB degree of freedom of the less-restricted model
nlow Lower bound of sample size
nhigh Upper bound of sample size
steps Step size
alpha The alpha level
group The number of group in calculating RMSEA
... The additional arguments for the plot function.
146 poolMAlloc
Author(s)
Bell Clinton
Pavel Panko (Texas Tech University; <[Link]@[Link]>)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
References
MacCallum, R. C., Browne, M. W., & Cai, L. (2006). Testing differences between nested covari-
ance structure models: Power analysis and null hypotheses. Psychological Methods, 11(1), 19–35.
doi:10.1037/1082989X.11.1.19
See Also
• findRMSEApowernested to find the power for a given sample size in nested model comparison
based on population RMSEA
• findRMSEAsamplesizenested to find the minium sample size for a given statistical power in
nested model comparison based on population RMSEA
Examples
Description
This function employs an iterative algorithm to pick the number of random item-to-parcel alloca-
tions needed to meet user-defined stability criteria for a fitted structural equation model (SEM) (see
Details below for more information). Pooled point and standard-error estimates from this SEM can
be outputted at this final selected number of allocations (however, it is more efficient to save the
allocations and treat them as multiple imputations using runMI; see See Also for links with exam-
ples). Additionally, new indices (see Sterba & Rights, 2016) are outputted for assessing the relative
contributions of parcel-allocation variability vs. sampling variability in each estimate. At each it-
eration, this function generates a given number of random item-to-parcel allocations, fits a SEM
to each allocation, pools estimates across allocations from that iteration, and then assesses whether
stopping criteria are met. If stopping criteria are not met, the algorithm increments the number of
allocations used (generating all new allocations).
poolMAlloc 147
Usage
poolMAlloc(nPerPar, facPlc, nAllocStart, nAllocAdd = 0,
parceloutput = NULL, syntax, dataset, stopProp, stopValue,
selectParam = NULL, indices = "default", double = FALSE,
checkConv = FALSE, names = "default", leaveout = 0,
useTotalAlloc = FALSE, ...)
Arguments
nPerPar A list in which each element is a vector, corresponding to each factor, indicat-
ing sizes of parcels. If variables are left out of parceling, they should not be
accounted for here (i.e., there should not be parcels of size "1").
facPlc A list of vectors, each corresponding to a factor, specifying the item indicators
of that factor (whether included in parceling or not). Either variable names or
column numbers. Variables not listed will not be modeled or included in output
datasets.
nAllocStart The number of random allocations of items to parcels to generate in the first
iteration of the algorithm.
nAllocAdd The number of allocations to add with each iteration of the algorithm. Note that
if only one iteration is desired, nAllocAdd can be set to 0 and results will be
output for nAllocStart allocationsonly.
parceloutput Optional character. Path (folder/directory) where M (the final selected number
of allocations) parceled data sets will be outputted from the iteration where the
algorithm met stopping criteria. Note for Windows users: file path must be
specified using forward slashes (/), not backslashes (\). See [Link] for
details. If NULL (default), nothing is saved to disk.
syntax lavaan syntax that defines the model.
dataset Item-level dataset
stopProp Value used in defining stopping criteria of the algorithm (δa in Sterba & Rights,
2016). This is the minimum proportion of change (in any pooled parameter or
pooled standard error estimate listed in selectParam) that is allowable from
one iteration of the algorithm to the next. That is, change in pooled estimates
and pooled standard errors from one iteration to the next must all be less than
(stopProp) x (value from former iteration). Note that stopValue can override
this criterion (see below). Also note that values less than .01 are unlikely to lead
to more substantively meaningful precision. Also note that if only stopValue is
a desired criterion, stopProp can be set to 0.
stopValue Value used in defining stopping criteria of the algorithm (δb in Sterba & Rights,
2016). stopValue is a minimum allowable amount of absolute change (in any
pooled parameter or pooled standard error estimate listed in selectParam) from
one iteration of the algorithm to the next. For a given pooled estimate or pooled
standard error, stopValue is only invoked as a stopping criteria when the min-
imum change required by stopProp is less than stopValue. Note that values
less than .01 are unlikely to lead to more substantively meaningful precision.
Also note that if only stopProp is a desired criterion, stopValue can be set to
0.
148 poolMAlloc
selectParam (Optional) A list of the pooled parameters to be used in defining stopping cri-
teria (i.e., stopProp and stopValue). These parameters should appear in the
order they are listed in the lavaan syntax. By default, all pooled parameters are
used. Note that selectParam should only contain freely-estimated parameters.
In one example from Sterba & Rights (2016) selectParam included all free pa-
rameters except item intercepts and in another example selectParam included
only structural parameters.
indices Optional character vector indicating the names of available fitMeasures to
be included in the output. The first and second elements should be a chi-
squared test statistic and its associated degrees of freedom, both of which will
be added if missing. If "default", the indices will be c("chisq", "df",
"cfi", "tli","rmsea","srmr"). If a robust test statistic is requested (see
lavOptions), c("chisq","df") will be replaced by c("[Link]","[Link]").
For the output to include both the naive and robust test statistics, indices should
include both, but put the scaled test statistics first, as in indices = c("[Link]",
"[Link]", "chisq", "df")
double (Optional) If set to TRUE, requires stopping criteria (stopProp and stopValue)
to be met for all parameters (in selectParam) for two consecutive iterations of
the algorithm. By default, this is set to FALSE, meaning stopping criteria need
only be met at one iteration of the algorithm.
checkConv (Optional) If set to TRUE, function will output pooled estimates and standard
errors from 10 iterations post-convergence.
names (Optional) A character vector containing the names of parceled variables.
leaveout (Optional) A vector of variables to be left out of randomized parceling. Either
variable names or column numbers are allowed.
useTotalAlloc (Optional) If set to TRUE, function will output a separate set of results that uses all
allocations created by the algorithm, rather than M allocations (see "Allocations
needed for stability" below). This distinction is further discussed in Sterba and
Rights (2016).
... Additional arguments to be passed to lavaan. See also lavOptions
Details
For further details on the benefits of the random allocation of items to parcels, see Sterba (2011)
and Sterba & MacCallum (2010).
This function implements an algorithm for choosing the number of allocations (M; described in
Sterba & Rights, 2016), pools point and standard-error estimates across these M allocations, and
produces indices for assessing the relative contributions of parcel-allocation variability vs. sampling
variability in each estimate.
To obtain pooled test statistics for model fit or model comparison, the list or parcel allocations can
be passed to runMI (find Examples on the help pages for parcelAllocation and PAVranking).
This function randomly generates a given number (nAllocStart) of item-to-parcel allocations, fits
a SEM to each allocation, and then increments the number of allocations used (by nAllocAdd) until
the pooled point and standard-error estimates fulfill stopping criteria (stopProp and stopValue,
defined above). A summary of results from the model that was fit to the M allocations are returned.
poolMAlloc 149
Additionally, this function outputs the proportion of allocations with solutions that converged (using
a maximum likelihood estimator) as well as the proportion of allocations with solutions that were
converged and proper. The converged and proper solutions among the final M allocations are used
in computing pooled results.
Additionally, after each iteration of the algorithm, information useful in monitoring the algorithm
is outputted. The number of allocations used at that iteration, the proportion of pooled parameter
estimates meeting stopping criteria at the previous iteration, the proportion of pooled standard errors
meeting stopping criteria at the previous iteration, and the runtime of that iteration are outputted.
When stopping criteria are satisfied, the full set of results are outputted.
Value
Estimates A table containing pooled results across M allocations at the iteration where
stopping criteria were met. Columns correspond to individual parameter name,
pooled estimate, pooled standard error, p-value for a z-test of the parameter,
z-based 95% confidence interval, p-value for a t-test of the parameter (using
degrees of freedom described in Sterba & Rights, 2016), and t-based 95% con-
fidence interval for the parameter.
Fit A table containing results related to model fit from the M allocations at the iter-
ation where stopping criteria were met. Columns correspond to fit index names,
the average of each index across allocations, the standard deviation of each fit
index across allocations, the maximum of each fit index across allocations, the
minimum of each fit index across allocations, the range of each fit index across
allocations, and the percent of the M allocations where the chi-square test of
absolute fit was significant.
Proportion of converged and proper allocations
A table containing the proportion of the final M allocations that converged (us-
ing a maximum likelihood estimator) and the proportion of allocations that con-
verged to proper solutions. Note that pooled estimates, pooled standard errors,
and other results are computed using only the converged, proper allocations.
Allocations needed for stability (M)
The number of allocations (M) at which the algorithm’s stopping criteria (de-
fined above) were met.
Indices used to quantify uncertainty in estimates due to sample vs. allocation variability
A table containing individual parameter names, an estimate of the proportion
of total variance of a pooled parameter estimate that is attributable to parcel-
allocation variability (PPAV), and an estimate of the ratio of the between-allocation
variance of a pooled parameter estimate to the within-allocation variance (RPAV).
See Sterba & Rights (2016) for more detail.
Total runtime (minutes)
The total runtime of the function, in minutes. Note that the total runtime will
be greater when the specified model encounters convergence problems for some
allocations, as is the case with the simParcel dataset used below.
Author(s)
Jason D. Rights (Vanderbilt University; <[Link]@[Link]>)
150 poolMAlloc
The author would also like to credit Corbin Quick and Alexander Schoemann for providing the
original parcelAllocation function on which this function is based.
References
Sterba, S. K. (2011). Implications of parcel-allocation variability for comparing fit of item-solutions
and parcel-solutions. Structural Equation Modeling, 18(4), 554–577. doi:10.1080/10705511.2011.607073
Sterba, S. K., & MacCallum, R. C. (2010). Variability in parameter estimates and model fit
across random allocations of items to parcels. Multivariate Behavioral Research, 45(2), 322–358.
doi:10.1080/00273171003680302
Sterba, S. K., & Rights, J. D. (2016). Accounting for parcel-allocation variability in practice:
Combining sources of uncertainty and choosing the number of allocations. Multivariate Behavioral
Research, 51(2–3), 296–313. doi:10.1080/00273171.2016.1144502
Sterba, S. K., & Rights, J. D. (2017). Effects of parceling on model selection: Parcel-allocation
variability in model ranking. Psychological Methods, 22(1), 47–68. doi:10.1037/met0000067
See Also
runMI for treating allocations as multiple imputations to pool results across allocations. See Exam-
ples on help pages for:
Examples
## Not run:
## lavaan syntax: A 2 Correlated
## factor CFA model to be fit to parceled data
## run function
poolMAlloc(nPerPar = list(c(3,3,3), c(3,3,3)),
facPlc = list(f1name, f2name), nAllocStart = 10, nAllocAdd = 10,
syntax = parmodel, dataset = simParcel, stopProp = .03,
stopValue = .03, selectParam = c(1:6, 13:18, 21),
names = list("p1f1","p2f1","p3f1","p1f2","p2f2","p3f2"),
double = FALSE, useTotalAlloc = FALSE)
## End(Not run)
Description
Probing interaction for simple intercept and simple slope for the no-centered or mean-centered
latent two-way interaction
Usage
probe2WayMC(fit, nameX, nameY, modVar, valProbe, group = 1L,
[Link] = c("[Link]", "[Link]"))
Arguments
fit A fitted lavaan or [Link] object with a latent 2-way interaction.
nameX character vector of all 3 factor names used as the predictors. The lower-order
factors must be listed first, and the final name must be the latent interaction
factor.
nameY The name of factor that is used as the dependent variable.
modVar The name of factor that is used as a moderator. The effect of the other inde-
pendent factor will be probed at each value of the moderator variable listed in
valProbe.
valProbe The values of the moderator that will be used to probe the effect of the focal
predictor.
152 probe2WayMC
group In multigroup models, the label of the group for which the results will be re-
turned. Must correspond to one of lavInspect(fit, "[Link]"), or an
integer corresponding to which of those group labels.
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Ignored unless fit is of class [Link]. Can include any of c("[Link]",
"[Link]", "[Link]"), the first 2 of which are the default setting, which excludes
any imputations that did not converge or for which standard errors could not be
computed. The last option ("[Link]") would exclude any imputations which
yielded a nonpositive definite covariance matrix for observed or latent variables,
which would include any "improper solutions" such as Heywood cases. NPD
solutions are not excluded by default because they are likely to occur due to
sampling error, especially in small samples. However, gross model misspecifi-
cation could also cause NPD solutions, users can compare pooled results with
and without this setting as a sensitivity analysis to see whether some imputations
warrant further investigation.
Details
Before using this function, researchers need to make the products of the indicators between the
first-order factors using mean centering (Marsh, Wen, & Hau, 2004). Note that the double-mean
centering may not be appropriate for probing interaction if researchers are interested in simple
intercepts. The mean or double-mean centering can be done by the indProd function. The indicator
products can be made for all possible combination or matched-pair approach (Marsh et al., 2004).
Next, the hypothesized model with the regression with latent interaction will be used to fit all
original indicators and the product terms. See the example for how to fit the product term below.
Once the lavaan result is obtained, this function will be used to probe the interaction.
Let that the latent interaction model regressing the dependent variable (Y ) on the independent
varaible (X) and the moderator (Z) be
Y = b0 + b1 X + b2 Z + b3 XZ + r,
where b0 is the estimated intercept or the expected value of Y when both X and Z are 0, b1 is the
effect of X when Z is 0, b2 is the effect of Z when X is 0, b3 is the interaction effect between X
and Z, and r is the residual term.
For probing two-way interaction, the simple intercept of the independent variable at each value of
the moderator (Aiken & West, 1991; Cohen, Cohen, West, & Aiken, 2003; Preacher, Curran, &
Bauer, 2006) can be obtained by
b0|X=0,Z = b0 + b2 Z.
The simple slope of the independent varaible at each value of the moderator can be obtained by
bX|Z = b1 + b3 Z.
where V ar denotes the variance of a parameter estimate and Cov denotes the covariance of two
parameter estimates.
probe2WayMC 153
Wald z statistic is used for test statistic (even for objects of class [Link]).
Value
A list with two elements:
1. SimpleIntercept: The intercepts given each value of the moderator. This element will be
NULL unless the factor intercept is estimated (e.g., not fixed at 0).
2. SimpleSlope: The slopes given each value of the moderator.
In each element, the first column represents the values of the moderators specified in the valProbe
argument. The second column is the simple intercept or simple slope. The third column is the SE of
the simple intercept or simple slope. The fourth column is the Wald (z) statistic. The fifth column
is the p value testing whether the simple intercepts or slopes are different from 0.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Tutorial:
Schoemann, A. M., & Jorgensen, T. D. (2021). Testing and interpreting latent variable interactions
using the semTools package. Psych, 3(3), 322–335. doi:10.3390/psych3030024
Background literature:
Aiken, L. S., & West, S. G. (1991). Multiple regression: Testing and interpreting interactions.
Newbury Park, CA: Sage.
Cohen, J., Cohen, P., West, S. G., & Aiken, L. S. (2003). Applied multiple regression/correlation
analysis for the behavioral sciences (3rd ed.). New York, NY: Routledge.
Marsh, H. W., Wen, Z., & Hau, K. T. (2004). Structural equation models of latent interactions:
Evaluation of alternative estimation strategies and indicator construction. Psychological Methods,
9(3), 275–300. doi:10.1037/1082989X.9.3.275
Preacher, K. J., Curran, P. J., & Bauer, D. J. (2006). Computational tools for probing interactions in
multiple linear regression, multilevel modeling, and latent curve analysis. Journal of Educational
and Behavioral Statistics, 31(4), 437–448. doi:10.3102/10769986031004437
See Also
• indProd For creating the indicator products with no centering, mean centering, double-mean
centering, or residual centering.
• probe3WayMC For probing the three-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
154 probe2WayMC
• probe2WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• probe3WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• plotProbe Plot the simple intercepts and slopes of the latent interaction.
Examples
Description
Probing interaction for simple intercept and simple slope for the residual-centered latent two-way
interaction (Geldhof et al., 2013)
Usage
Arguments
Details
Before using this function, researchers need to make the products of the indicators between the first-
order factors and residualize the products by the original indicators (Lance, 1988; Little, Bovaird,
& Widaman, 2006). The process can be automated by the indProd function. Note that the indicator
products can be made for all possible combination or matched-pair approach (Marsh et al., 2004).
Next, the hypothesized model with the regression with latent interaction will be used to fit all
original indicators and the product terms. To use this function the model must be fit with a mean
structure. See the example for how to fit the product term below. Once the lavaan result is obtained,
this function will be used to probe the interaction.
The probing process on residual-centered latent interaction is based on transforming the residual-
centered result into the no-centered result. See Geldhof et al. (2013) for further details. Note
that this approach based on a strong assumption that the first-order latent variables are normally
distributed. The probing process is applied after the no-centered result (parameter estimates and
their covariance matrix among parameter estimates) has been computed. See the probe2WayMC for
further details.
Value
A list with two elements:
1. SimpleIntercept: The intercepts given each value of the moderator. This element will be
NULL unless the factor intercept is estimated (e.g., not fixed at 0).
2. SimpleSlope: The slopes given each value of the moderator.
In each element, the first column represents the values of the moderators specified in the valProbe
argument. The second column is the simple intercept or simple slope. The third column is the
standard error of the simple intercept or simple slope. The fourth column is the Wald (z) statistic.
The fifth column is the p value testing whether the simple intercepts or slopes are different from 0.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Tutorial:
Schoemann, A. M., & Jorgensen, T. D. (2021). Testing and interpreting latent variable interactions
using the semTools package. Psych, 3(3), 322–335. doi:10.3390/psych3030024
Background literature:
Lance, C. E. (1988). Residual centering, exploratory and confirmatory moderator analysis, and de-
composition of effects in path models containing interactions. Applied Psychological Measurement,
12(2), 163–175. doi:10.1177/014662168801200205
Little, T. D., Bovaird, J. A., & Widaman, K. F. (2006). On the merits of orthogonalizing powered
and product terms: Implications for modeling interactions. Structural Equation Modeling, 13(4),
497–519. doi:10.1207/s15328007sem1304_1
probe2WayRC 157
Marsh, H. W., Wen, Z., & Hau, K. T. (2004). Structural equation models of latent interactions:
Evaluation of alternative estimation strategies and indicator construction. Psychological Methods,
9(3), 275–300. doi:10.1037/1082989X.9.3.275
Geldhof, G. J., Pornprasertmanit, S., Schoemann, A. M., & Little, T. D. (2013). Orthogonalizing
through residual centering: Extended applications and caveats. Educational and Psychological
Measurement, 73(1), 27–46. doi:10.1177/0013164412445473
See Also
• indProd For creating the indicator products with no centering, mean centering, double-mean
centering, or residual centering.
• probe2WayMC For probing the two-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe3WayMC For probing the three-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe3WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• plotProbe Plot the simple intercepts and slopes of the latent interaction.
Examples
Description
Probing interaction for simple intercept and simple slope for the no-centered or mean-centered
latent two-way interaction
Usage
probe3WayMC(fit, nameX, nameY, modVar, valProbe1, valProbe2, group = 1L,
[Link] = c("[Link]", "[Link]"))
Arguments
fit A fitted lavaan or [Link] object with a latent 2-way interaction.
nameX character vector of all 7 factor names used as the predictors. The 3 lower-order
factors must be listed first, followed by the 3 second-order factors (specifically,
the 4th element must be the interaction between the factors listed first and sec-
ond, the 5th element must be the interaction between the factors listed first and
third, and the 6th element must be the interaction between the factors listed
second and third). The final name will be the factor representing the 3-way
interaction.
nameY The name of factor that is used as the dependent variable.
modVar The name of two factors that are used as the moderators. The effect of the
independent factor on each combination of the moderator variable values will
be probed.
valProbe1 The values of the first moderator that will be used to probe the effect of the
independent factor.
valProbe2 The values of the second moderator that will be used to probe the effect of the
independent factor.
group In multigroup models, the label of the group for which the results will be re-
turned. Must correspond to one of lavInspect(fit, "[Link]").
probe3WayMC 159
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Ignored unless fit is of class [Link]. Can include any of c("[Link]",
"[Link]", "[Link]"), the first 2 of which are the default setting, which excludes
any imputations that did not converge or for which standard errors could not be
computed. The last option ("[Link]") would exclude any imputations which
yielded a nonpositive definite covariance matrix for observed or latent variables,
which would include any "improper solutions" such as Heywood cases. NPD
solutions are not excluded by default because they are likely to occur due to
sampling error, especially in small samples. However, gross model misspecifi-
cation could also cause NPD solutions, users can compare pooled results with
and without this setting as a sensitivity analysis to see whether some imputations
warrant further investigation.
Details
Before using this function, researchers need to make the products of the indicators between the
first-order factors using mean centering (Marsh, Wen, & Hau, 2004). Note that the double-mean
centering may not be appropriate for probing interaction if researchers are interested in simple
intercepts. The mean or double-mean centering can be done by the indProd function. The indicator
products can be made for all possible combination or matched-pair approach (Marsh et al., 2004).
Next, the hypothesized model with the regression with latent interaction will be used to fit all
original indicators and the product terms. See the example for how to fit the product term below.
Once the lavaan result is obtained, this function will be used to probe the interaction.
Let that the latent interaction model regressing the dependent variable (Y ) on the independent
varaible (X) and two moderators (Z and W ) be
Y = b0 + b1 X + b2 Z + b3 W + b4 XZ + b5 XW + b6 ZW + b7 XZW + r,
where b0 is the estimated intercept or the expected value of Y when X, Z, and W are 0, b1 is the
effect of X when Z and W are 0, b2 is the effect of Z when X and W is 0, b3 is the effect of W
when X and Z are 0, b4 is the interaction effect between X and Z when W is 0, b5 is the interaction
effect between X and W when Z is 0, b6 is the interaction effect between Z and W when X is 0,
b7 is the three-way interaction effect between X, Z, and W , and r is the residual term.
For probing three-way interaction, the simple intercept of the independent variable at the specific
values of the moderators (Aiken & West, 1991) can be obtained by
b0|X=0,Z,W = b0 + b2 Z + b3 W + b6 ZW.
The simple slope of the independent varaible at the specific values of the moderators can be obtained
by
bX|Z,W = b1 + b3 Z + b4 W + b7 ZW.
The variance of the simple intercept formula is
V ar b0|X=0,Z,W = V ar (b0 )+Z 2 V ar (b2 )+W 2 V ar (b3 )+Z 2 W 2 V ar (b6 )+2ZCov (b0 , b2 )+2W Cov (b0 , b3 )+2ZW Co
where V ar denotes the variance of a parameter estimate and Cov denotes the covariance of two
parameter estimates.
The variance of the simple slope formula is
V ar bX|Z,W = V ar (b1 )+Z 2 V ar (b4 )+W 2 V ar (b5 )+Z 2 W 2 V ar (b7 )+2ZCov (b1 , b4 )+2W Cov (b1 , b5 )+2ZW Cov (b
Wald z statistic is used for test statistic (even for objects of class [Link]).
160 probe3WayMC
Value
1. SimpleIntercept: The intercepts given each combination of moderator values. This element
will be shown only if the factor intercept is estimated (e.g., not fixed at 0).
2. SimpleSlope: The slopes given each combination of moderator values.
In each element, the first column represents values of the first moderator specified in the valProbe1
argument. The second column represents values of the second moderator specified in the valProbe2
argument. The third column is the simple intercept or simple slope. The fourth column is the
standard error of the simple intercept or simple slope. The fifth column is the Wald (z) statistic. The
sixth column is the p value testing whether the simple intercepts or slopes are different from 0.
Author(s)
References
Tutorial:
Schoemann, A. M., & Jorgensen, T. D. (2021). Testing and interpreting latent variable interactions
using the semTools package. Psych, 3(3), 322–335. doi:10.3390/psych3030024
Background literature:
Aiken, L. S., & West, S. G. (1991). Multiple regression: Testing and interpreting interactions.
Newbury Park, CA: Sage.
Marsh, H. W., Wen, Z., & Hau, K. T. (2004). Structural equation models of latent interactions:
Evaluation of alternative estimation strategies and indicator construction. Psychological Methods,
9(3), 275–300. doi:10.1037/1082989X.9.3.275
See Also
• indProd For creating the indicator products with no centering, mean centering, double-mean
centering, or residual centering.
• probe2WayMC For probing the two-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe2WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• probe3WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• plotProbe Plot the simple intercepts and slopes of the latent interaction.
probe3WayRC 161
Examples
Description
Probing interaction for simple intercept and simple slope for the residual-centered latent three-way
interaction (Geldhof et al., 2013)
162 probe3WayRC
Usage
probe3WayRC(fit, nameX, nameY, modVar, valProbe1, valProbe2, group = 1L,
[Link] = c("[Link]", "[Link]"))
Arguments
fit A fitted lavaan or [Link] object with a latent 2-way interaction.
nameX character vector of all 7 factor names used as the predictors. The 3 lower-order
factors must be listed first, followed by the 3 second-order factors (specifically,
the 4th element must be the interaction between the factors listed first and sec-
ond, the 5th element must be the interaction between the factors listed first and
third, and the 6th element must be the interaction between the factors listed
second and third). The final name will be the factor representing the 3-way
interaction.
nameY The name of factor that is used as the dependent variable.
modVar The name of two factors that are used as the moderators. The effect of the
independent factor on each combination of the moderator variable values will
be probed.
valProbe1 The values of the first moderator that will be used to probe the effect of the
independent factor.
valProbe2 The values of the second moderator that will be used to probe the effect of the
independent factor.
group In multigroup models, the label of the group for which the results will be re-
turned. Must correspond to one of lavInspect(fit, "[Link]").
[Link] character vector specifying criteria for omitting imputations from pooled re-
sults. Ignored unless fit is of class [Link]. Can include any of c("[Link]",
"[Link]", "[Link]"), the first 2 of which are the default setting, which excludes
any imputations that did not converge or for which standard errors could not be
computed. The last option ("[Link]") would exclude any imputations which
yielded a nonpositive definite covariance matrix for observed or latent variables,
which would include any "improper solutions" such as Heywood cases. NPD
solutions are not excluded by default because they are likely to occur due to
sampling error, especially in small samples. However, gross model misspecifi-
cation could also cause NPD solutions, users can compare pooled results with
and without this setting as a sensitivity analysis to see whether some imputations
warrant further investigation.
Details
Before using this function, researchers need to make the products of the indicators between the first-
order factors and residualize the products by the original indicators (Lance, 1988; Little, Bovaird,
& Widaman, 2006). The process can be automated by the indProd function. Note that the indicator
products can be made for all possible combination or matched-pair approach (Marsh et al., 2004).
Next, the hypothesized model with the regression with latent interaction will be used to fit all
original indicators and the product terms (Geldhof et al., 2013). To use this function the model
must be fit with a mean structure. See the example for how to fit the product term below. Once the
lavaan result is obtained, this function will be used to probe the interaction.
probe3WayRC 163
The probing process on residual-centered latent interaction is based on transforming the residual-
centered result into the no-centered result. See Geldhof et al. (2013) for further details. Note
that this approach based on a strong assumption that the first-order latent variables are normally
distributed. The probing process is applied after the no-centered result (parameter estimates and
their covariance matrix among parameter estimates) has been computed. See the probe3WayMC for
further details.
Value
A list with two elements:
1. SimpleIntercept: The intercepts given each value of the moderator. This element will be
shown only if the factor intercept is estimated (e.g., not fixed as 0).
2. SimpleSlope: The slopes given each value of the moderator.
In each element, the first column represents values of the first moderator specified in the valProbe1
argument. The second column represents values of the second moderator specified in the valProbe2
argument. The third column is the simple intercept or simple slope. The fourth column is the SE of
the simple intercept or simple slope. The fifth column is the Wald (z) statistic. The sixth column is
the p value testing whether the simple intercepts or slopes are different from 0.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Tutorial:
Schoemann, A. M., & Jorgensen, T. D. (2021). Testing and interpreting latent variable interactions
using the semTools package. Psych, 3(3), 322–335. doi:10.3390/psych3030024
Background literature:
Geldhof, G. J., Pornprasertmanit, S., Schoemann, A., & Little, T. D. (2013). Orthogonalizing
through residual centering: Extended applications and caveats. Educational and Psychological
Measurement, 73(1), 27–46. doi:10.1177/0013164412445473
Lance, C. E. (1988). Residual centering, exploratory and confirmatory moderator analysis, and de-
composition of effects in path models containing interactions. Applied Psychological Measurement,
12(2), 163–175. doi:10.1177/014662168801200205
Little, T. D., Bovaird, J. A., & Widaman, K. F. (2006). On the merits of orthogonalizing powered
and product terms: Implications for modeling interactions. Structural Equation Modeling, 13(4),
497–519. doi:10.1207/s15328007sem1304_1
Marsh, H. W., Wen, Z., & Hau, K. T. (2004). Structural equation models of latent interactions:
Evaluation of alternative estimation strategies and indicator construction. Psychological Methods,
9(3), 275–300. doi:10.1037/1082989X.9.3.275
Pornprasertmanit, S., Schoemann, A. M., Geldhof, G. J., & Little, T. D. (submitted). Probing latent
interaction estimated with a residual centering approach.
164 probe3WayRC
See Also
• indProd For creating the indicator products with no centering, mean centering, double-mean
centering, or residual centering.
• probe2WayMC For probing the two-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe3WayMC For probing the three-way latent interaction when the results are obtained from
mean-centering, or double-mean centering
• probe2WayRC For probing the two-way latent interaction when the results are obtained from
residual-centering approach.
• plotProbe Plot the simple intercepts and slopes of the latent interaction.
Examples
quark Quark
Description
The quark function provides researchers with the ability to calculate and include component scores
calculated by taking into account the variance in the original dataset and all of the interaction and
polynomial effects of the data in the dataset.
Usage
quark(data, id, order = 1, silent = FALSE, ...)
Arguments
data The data frame is a required component for quark. In order for quark to process
a data frame, it must not contain any factors or text-based variables. All variables
must be in numeric format. Identifiers and dates can be left in the data; however,
they will need to be identified under the id argument.
id Identifiers and dates within the dataset will need to be acknowledged as quark
cannot process these. By acknowledging the identifiers and dates as a vector
of column numbers or variable names, quark will remove them from the data
temporarily to complete its main processes. Among many potential issues of not
acknowledging identifiers and dates are issues involved with imputation, product
and polynomial effects, and principal component analysis.
order Order is an optional argument provided by quark that can be used when the
imputation procedures in mice fail. Under some circumstances, mice cannot
calculate missing values due to issues with extreme missingness. Should an
error present itself stating a failure due to not having any columns selected, set
the argument order = 2 in order to reorder the imputation method procedure.
Otherwise, use the default order = 1.
silent If FALSE, the details of the quark process are printed.
... additional arguments to pass to mice.
Details
The quark function calculates these component scores by first filling in the data via means of mul-
tiple imputation methods and then expanding the dataset by aggregating the non-overlapping inter-
action effects between variables by calculating the mean of the interactions and polynomial effects.
The multiple imputation methods include one of iterative sampling and group mean substitution and
multiple imputation using a polytomous regression algorithm (mice). During the expansion process,
the dataset is expanded to three times its normal size (in width). The first third of the dataset con-
tains all of the original data post imputation, the second third contains the means of the polynomial
166 quark
effects (squares and cubes), and the final third contains the means of the non-overlapping interac-
tion effects. A full principal componenent analysis is conducted and the individual components are
retained. The subsequent combinequark function provides researchers the control in determining
how many components to extract and retain. The function returns the dataset as submitted (with
missing values) and the component scores as requested for a more accurate multiple imputation in
subsequent steps.
Value
The output value from using the quark function is a list. It will return a list with 7 components.
Author(s)
References
Howard, W. J., Rhemtulla, M., & Little, T. D. (2015). Using Principal Components as Auxil-
iary Variables in Missing Data Estimation. Multivariate Behavioral Research, 50(3), 285–299.
doi:10.1080/00273171.2014.999267
See Also
combinequark
residualCovariate 167
Examples
[Link](123321)
## End(Not run)
Description
This function will regress target variables on the covariate and replace the target variables by the
residual of the regression analysis. This procedure is useful to control the covariate from the analysis
model (Geldhof, Pornprasertmanit, Schoemann, & Little, 2013).
Usage
residualCovariate(data, targetVar, covVar)
Arguments
data The desired data to be transformed.
targetVar Varible names or the position of indicators that users wish to be residual centered
(as dependent variables)
covVar Covariate names or the position of the covariates using for residual centering (as
independent variables) onto target variables
Value
The data that the target variables replaced by the residuals
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
168 runMI
References
Geldhof, G. J., Pornprasertmanit, S., Schoemann, A. M., & Little, T. D. (2013). Orthogonalizing
through residual centering: Extended applications and caveats. Educational and Psychological
Measurement, 73(1), 27–46. doi:10.1177/0013164412445473
See Also
indProd For creating the indicator products with no centering, mean centering, double-mean cen-
tering, or residual centering.
Examples
Description
This function fits a lavaan model to a list of imputed data sets, and can also implement multiple
imputation for a single [Link] with missing observations, using either the Amelia package or
the mice package.
Usage
runMI(model, data, fun = "lavaan", ..., m, miArgs = list(),
miPackage = "Amelia", seed = 12345)
Arguments
model The analysis model can be specified using lavaan [Link] or a parameter
table (as returned by parTable).
runMI 169
data A [Link] with missing observations, or a list of imputed data sets (if data
are imputed already). If runMI has already been called, then imputed data sets
are stored in the @DataList slot, so data can also be a [Link] object from
which the same imputed data will be used for additional analyses.
fun character. Name of a specific lavaan function used to fit model to data (i.e.,
"lavaan", "cfa", "sem", or "growth"). Only required for runMI.
... additional arguments to pass to lavaan or lavaanList. See also lavOptions.
Note that lavaanList provides parallel computing options, as well as a FUN
argument so the user can extract custom output after the model is fitted to each
imputed data set (see Examples). TIP: If a custom FUN is used and parallel =
"snow" is requested, the user-supplied function should explicitly call library
or use :: for any functions not part of the base distribution.
m integer. Request the number of imputations. Ignored if data is already a list
of imputed data sets or a [Link] object.
miArgs Addition arguments for the multiple-imputation function (miPackage). The ar-
guments should be put in a list (see example below). Ignored if data is already
a list of imputed data sets or a [Link] object.
miPackage Package to be used for imputation. Currently these functions only support
"Amelia" or "mice" for imputation. Ignored if data is already a list of im-
puted data sets or a [Link] object.
seed integer. Random number seed to be set before imputing the data. Ignored if
data is already a list of imputed data sets or a [Link] object.
Value
A [Link] object
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York, NY: Wiley.
Examples
## Not run:
## impose missing data for example
HSMiss <- HolzingerSwineford1939[ , c(paste("x", 1:9, sep = ""),
"ageyr","agemo","school")]
[Link](12345)
HSMiss$x5 <- ifelse(HSMiss$x5 <= quantile(HSMiss$x5, .3), NA, HSMiss$x5)
age <- HSMiss$ageyr + HSMiss$agemo/12
HSMiss$x9 <- ifelse(age <= quantile(age, .3), NA, HSMiss$x9)
## same results (using the same seed results in the same imputations)
cbind([Link] = coef(out1), [Link] = coef(out2))
## Wald test of whether latent means are == (fix 3 means to zero in group 2)
[Link] <- ' .p70. == 0
.p71. == 0
.p72. == 0 '
[Link]([Link], constraints = [Link])
## ordered-categorical data
data(datCat)
lapply(datCat, class) # indicators already stored as ordinal
## impose missing values
[Link](123)
for (i in 1:8) datCat[sample(1:nrow(datCat), size = .1*nrow(datCat)), i] <- NA
## fit model, save zero-cell tables and obsolete "WRMR" fit indices
catout <- [Link](' f =~ 1*u1 + 1*u2 + 1*u3 + 1*u4 ', data = impList,
FUN = function(fit) {
list(wrmr = lavaan::fitMeasures(fit, "wrmr"),
zeroCells = lavaan::lavInspect(fit, "[Link]"))
})
summary(catout)
[Link](catout, test = "D2", [Link] = TRUE)
fitMeasures(catout, [Link] = c("rmsea","srmr","cfi"),
test = "D2", [Link] = TRUE)
## End(Not run)
172 simParcel
Description
The semTools package provides many miscellaneous functions that are useful for statistical analysis
involving SEM in R. Many functions extend the funtionality of the lavaan package. Some sets of
functions in semTools correspond to the same theme. We call such a collection of functions a suite.
Our suites include:
All users of R (or SEM) are invited to submit functions or ideas for functions by contacting the
maintainer, Terrence Jorgensen (<TJorgensen314@[Link]>). Contributors are encouraged to
use Roxygen comments to document their contributed code, which is consistent with the rest of
semTools. Read the vignette from the roxygen2 package for details: vignette("rd", package =
"roxygen2")
Description
A simulated data set with 2 factors with 9 indicators for each factor
Usage
simParcel
singleParamTest 173
Format
A [Link] with 800 observations of 18 variables.
f1item1 Item 1 loading on factor 1
f1item2 Item 2 loading on factor 1
f1item3 Item 3 loading on factor 1
f1item4 Item 4 loading on factor 1
f1item5 Item 5 loading on factor 1
f1item6 Item 6 loading on factor 1
f1item7 Item 7 loading on factor 1
f1item8 Item 8 loading on factor 1
f1item9 Item 9 loading on factor 1
f2item1 Item 1 loading on factor 2
f2item2 Item 2 loading on factor 2
f2item3 Item 3 loading on factor 2
f2item4 Item 4 loading on factor 2
f2item5 Item 5 loading on factor 2
f2item6 Item 6 loading on factor 2
f2item7 Item 7 loading on factor 2
f2item8 Item 8 loading on factor 2
f2item9 Item 9 loading on factor 2
Source
Data were generated using the simsem package.
Examples
head(simParcel)
Description
In comparing two nested models, ∆χ2 test may indicate that two models are different. However,
like other omnibus tests, researchers do not know which fixed parameters or constraints make these
two models different. This function will help researchers identify the significant parameter.
Usage
singleParamTest(model1, model2, [Link] = FALSE,
method = "[Link].2001")
174 singleParamTest
Arguments
model1 Model 1.
model2 Model 2. Note that two models must be nested models. Further, the order of
parameters in their parameter tables are the same. That is, nested models with
different scale identifications may not be able to test by this function.
[Link] Return the submodels fitted by this function
method The method used to calculate likelihood ratio test. See lavTestLRT for available
options
Details
This function first identifies the differences between these two models. The model with more free
parameters is referred to as parent model and the model with fewer free parameters is referred to as
nested model. Two tests are implemented here:
1. free: The nested model is used as a template. Then, one parameter indicating the differences
between two models is freed. The new model is compared with the nested model. This process
is repeated for all differences between two models.
2. fix: The parent model is used as a template. Then, one parameter indicating the differences
between two models is fixed or constrained to be equal to other parameters. The new model
is then compared with the parent model. This process is repeated for all differences between
two models.
3. mi: No longer available because the test of modification indices is not consistent. For example,
if two parameters are equality constrained, the modification index from the first parameter is
not equal to the second parameter.
Note that this function does not adjust for the inflated Type I error rate from multiple tests.
Value
If [Link] = FALSE, the result tables are provided. χ2 and p value are provided for all methods.
Note that the χ2 is all based on 1 df. Expected parameter changes and their standardized forms are
also provided.
If [Link] = TRUE, a list with two elements are provided. The first element is the tabular result.
The second element is the submodels used in the free and fix methods.
Author(s)
Sunthud Pornprasertmanit (<psunthud@[Link]>)
Examples
library(lavaan)
## Note that the comparison between metric (Model 2) and scalar invariance
## (Model 3) cannot be done by this function because the metric invariance
## model fixes factor means as 0 in Group 2 but the strong invariance model
## frees the factor means in Group 2. Users may use this function to compare
## scalar invariance (Model 3) to a homogeneous-means model.
Description
Finding skewness (g1 ) of an object
Usage
skew(object, population = FALSE)
Arguments
object A vector used to find a skewness
population TRUE to compute the parameter formula. FALSE to compute the sample statistic
formula.
Details
The skewness computed by default is g1 , the third standardized moment of the empirical distribution
of object. The population parameter skewness γ1 formula is
µ3
γ1 = 3/2
,
µ2
176 skew
k3
g1 = ,
k22
6
V ar(ĝ1 ) =
N
Value
Author(s)
References
Weisstein, Eric W. (n.d.). Skewness. Retrived from MathWorld–A Wolfram Web Resource: http:
//[Link]/[Link]
See Also
Examples
skew(1:5)
splitSample 177
Description
This function randomly splits a data set into two halves, and saves the resulting data sets to the same
folder as the original.
Usage
splitSample(dataset, path = "default", div = 2, type = "default",
name = "splitSample")
Arguments
dataset The original data set to be divided. Can be a file path to a *.csv or *.dat file
(headers will automatically be detected) or an R object (matrix or dataframe).
(Windows users: file path must be specified using FORWARD SLASHES (/)
ONLY.)
path File path to folder for output data sets. NOT REQUIRED if dataset is a filename.
Specify ONLY if dataset is an R object, or desired output folder is not that of
original data set. If path is specified as "object", output data sets will be returned
as a list, and not saved to hard drive.
div Number of output data sets. NOT REQUIRED if default, 2 halves.
type Output file format ("dat" or "csv"). NOT REQUIRED unless desired output
formatting differs from that of input, or dataset is an R object and csv formatting
is desired.
name Output file name. NOT REQUIRED unless desired output name differs from
that of input, or input dataset is an R object. (If input is an R object and name is
not specified, name will be "splitSample".)
Details
This function randomly orders the rows of a data set, divides the data set into two halves, and saves
the halves to the same folder as the original data set, preserving the original formatting. Data set
type (*.csv or *.dat) and formatting (headers) are automatically detected, and output data sets will
preserve input type and formatting unless specified otherwise. Input can be in the form of a file path
(*.dat or *.csv), or an R object (matrix or dataframe). If input is an R object and path is default,
output data sets will be returned as a list object.
Value
If path = "object", list of output data sets. Otherwise, output will saved to hard drive in the
same format as input.
178 SSpower
Author(s)
Examples
Description
Apply Satorra & Saris (1985) method for chi-squared power analysis.
Usage
Arguments
powerModel lavaan [Link] for the model to be analyzed. This syntax should con-
strain at least one nonzero parameter to 0 (or another number).
SSpower 179
Details
Specify all non-zero parameters in a population model, either by using lavaan syntax (popModel) or
by submitting a population covariance matrix (Sigma) and optional mean vector (mu) implied by the
population model. Then specify an analysis model that places at least one invalid constraint (note
the number in the nparam argument).
There is also a Shiny app called "power4SEM" that provides a graphical user interface for this func-
tionality (Jak et al., in press). It can be accessed at [Link]
Author(s)
References
Satorra, A., & Saris, W. E. (1985). Power of the likelihood ratio test in covariance structure analysis.
Psychometrika, 50(1), 83–90. doi:10.1007/BF02294150
Jak, S., Jorgensen, T. D., Verdam, M. G., Oort, F. J., & Elffers, L. (2021). Analytical power cal-
culations for structural equation modeling: A tutorial and Shiny app. Behavior Research Methods,
53, 1385–1406. doi:10.3758/s13428020014790
180 SSpower
Examples
V8 ~~ .51*V8
'
modelA2 <- '
f1 =~ V1 + V2 + V3 + V4
f2 =~ V5 + V6 + V7 + V8
f1 ~~ c(psi21, psi21)*f2 # EQUALITY CONSTRAINT ACROSS GROUPS
'
## Calculate power
SSpower(powerModel = modelA2, popModel = modelP2, n = c(100, 100), nparam = 1,
[Link] = TRUE)
## Get power for a range of sample sizes
Ns2 <- cbind(Group1 = seq(10, 100, 10), Group2 = seq(10, 100, 10))
Power2 <- apply(Ns2, MARGIN = 1, FUN = function(nn) {
SSpower(powerModel = modelA2, popModel = modelP2, n = nn,
nparam = 1, [Link] = TRUE)
})
plot(x = rowSums(Ns2), y = Power2, type = "l", xlab = "Total Sample Size",
ylim = 0:1)
abline(h = c(.8, .9), lty = c("dotted","dashed"))
legend("bottomright", c("80% Power","90% Power"), lty = c("dotted","dashed"))
tukeySEM Tukey’s WSD post-hoc test of means for unequal variance and sample
size
Description
This function computes Tukey’s WSD post hoc test of means when variances and sample sizes are
not equal across groups. It can be used as a post hoc test when comparing latent means in multiple
group SEM.
Usage
tukeySEM(m1, m2, var1, var2, n1, n2, ng)
Arguments
m1 Mean of group 1.
m2 Mean of group 2.
var1 Variance of group 1.
var2 Variance of group 2.
n1 Sample size of group 1.
n2 Sample size of group 2.
ng Total number of groups to be compared (i.e., the number of groups compared in
the omnibus test).
182 tukeySEM
Details
After conducting an omnibus test of means across three of more groups, researchers often wish
to know which sets of means differ at a particular Type I error rate. Tukey’s WSD test holds the
error rate stable across multiple comparisons of means. This function implements an adaptation of
Tukey’s WSD test from Maxwell & Delaney (2004), that allows variances and sample sizes to differ
across groups.
Value
1. q: The q statistic
2. df: The degrees of freedom for the q statistic
3. p: A p value based on the q statistic, df, and the total number of groups to be compared
Author(s)
References
Maxwell, S. E., & Delaney, H. D. (2004). Designing experiments and analyzing data: A model
comparison perspective (2nd ed.). Mahwah, NJ: Lawrence Erlbaum Associates.
Examples
twostage Fit a lavaan model using 2-Stage Maximum Likelihood (TSML) esti-
mation for missing data.
Description
This function automates 2-Stage Maximum Likelihood (TSML) estimation, optionally with auxil-
iary variables. Step 1 involves fitting a saturated model to the partially observed data set (to variables
in the hypothesized model as well as auxiliary variables related to missingness). Step 2 involves
fitting the hypothesized model to the model-implied means and covariance matrix (also called the
"EM" means and covariance matrix) as if they were complete data. Step 3 involves correcting the
Step-2 standard errors (SEs) and chi-squared statistic to account for additional uncertainty due to
missing data (using information from Step 1; see References section for sources with formulas).
Usage
twostage(..., aux, fun, [Link] = NULL)
Arguments
... Arguments passed to the lavaan function specified in the fun argument. See
also lavOptions. At a minimum, the user must supply the first two named
arguments to lavaan (i.e., model and data).
aux An optional character vector naming auxiliary variable(s) in data
fun The character string naming the lavaan function used to fit the Step-2 hypothe-
sized model ("cfa", "sem", "growth", or "lavaan").
[Link] An optional character string, specifying the lavaan [Link] for a user-
specified baseline model. Interested users can use the fitted baseline model to
calculate incremental fit indices (e.g., CFI and TLI) using the corrected chi-
squared values (see the anova method in twostage). If NULL, the default "inde-
pendence model" (i.e., freely estimated means and variances, but all covariances
constrained to zero) will be specified internally.
Details
All variables (including auxiliary variables) are treated as endogenous varaibles in the Step-1 sat-
urated model (fixed.x = FALSE), so data are assumed continuous, although not necessarily mul-
tivariate normal (dummy-coded auxiliary variables may be included in Step 1, but categorical en-
184 twostage
dogenous variables in the Step-2 hypothesized model are not allowed). To avoid assuming multi-
variate normality, request se = "[Link]". CAUTION: In addition to setting fixed.x
= FALSE and conditional.x = FALSE in lavaan, this function will automatically set meanstructure
= TRUE, estimator = "ML", missing = "fiml", and test = "standard". lavaan’s se option can
only be set to "standard" to assume multivariate normality or to "[Link]" to relax
that assumption.
Value
The twostage object contains 3 fitted lavaan models (saturated, target/hypothesized, and baseline)
as well as the names of auxiliary variables. None of the individual models provide the correct model
results (except the point estimates in the target model are unbiased). Use the methods in twostage
to extract corrected SEs and test statistics.
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
References
Savalei, V., & Bentler, P. M. (2009). A two-stage approach to missing data: Theory and ap-
plication to auxiliary variables. Structural Equation Modeling, 16(3), 477–497. doi:10.1080/
10705510903008238
Savalei, V., & Falk, C. F. (2014). Robust two-stage approach outperforms robust full information
maximum likelihood with incomplete nonnormal data. Structural Equation Modeling, 21(2), 280–
302. doi:10.1080/10705511.2014.882692
See Also
twostage
Examples
twostage-class Class for the Results of 2-Stage Maximum Likelihood (TSML) Estima-
tion for Missing Data
Description
This class contains the results of 2-Stage Maximum Likelihood (TSML) estimation for missing
data. The summary, anova, vcov methods return corrected SEs and test statistics. Other methods
are simply wrappers around the corresponding lavaan methods.
Usage
## S4 method for signature 'twostage'
show(object)
Arguments
object An object of class twostage.
... arguments passed to parameterEstimates.
h1 An object of class twostage in which object is nested, so that their difference
in fit can be tested using anova (see Value section for details).
baseline logical indicating whether to return results for the baseline model, rather than
the default target (hypothesized) model.
type The meaning of this argument varies depending on which method it it used
for. Find detailed descriptions in the Value section under coef, nobs, and
residuals.
model character naming the slot for which to return the model-implied sample mo-
ments (see [Link] description.)
labels logical indicating whether the model-implied sample moments should have
(row/column) labels.
Value
show signature(object = "twostage"): The show function is used to display the
results of the anova method, as well as the header of the (uncorrected) target
model results.
summary signature(object = "twostage", ...): The summary function prints the same
information from the show method, but also provides (and returns) the output of
parameterEstimates(object@target, ...) with corrected SEs, test statis-
tics, and confidence intervals. Additional arguments can be passed to parameterEstimates,
twostage-class 187
Slots
saturated A fitted lavaan object containing the saturated model results
target A fitted lavaan object containing the target/hypothesized model results
baseline A fitted lavaan object containing the baseline/null model results
auxNames A character string (potentially of length == 0) of any auxiliary variable names, if used
Author(s)
Terrence D. Jorgensen (University of Amsterdam; <TJorgensen314@[Link]>)
188 twostage-class
See Also
twostage
Examples
189
190 INDEX
vcov,[Link]-method
([Link]-class), 56
vcov,twostage-method (twostage-class),
185
[Link], 10, 15