modsem_pi() is a function for estimating interaction effects between latent variables,
in structural equation models (SEMs), using product indicators.
Methods for estimating interaction effects in SEMs can basically be split into
two frameworks:
1. Product Indicator based approaches ("dblcent", "rca", "uca",
"ca", "pind"), and
2. Distributionally based approaches ("lms", "qml").
modsem_pi() is essentially a fancy wrapper for lavaan::sem() which generates the
necessary syntax and variables for the estimation of models with latent product indicators.
Use default_settings_pi() to get the default settings for the different methods.
modsem_pi(
model.syntax = NULL,
data = NULL,
method = "dblcent",
match = NULL,
match.recycle = NULL,
standardize.data = FALSE,
center.data = FALSE,
first.loading.fixed = FALSE,
center.before = NULL,
center.after = NULL,
residuals.prods = NULL,
residual.cov.syntax = NULL,
constrained.prod.mean = NULL,
constrained.loadings = NULL,
constrained.var = NULL,
res.cov.method = NULL,
res.cov.across = NULL,
composite.int.res.cov = FALSE,
auto.scale = "none",
auto.center = "none",
estimator = "ML",
group = NULL,
cluster = NULL,
run = TRUE,
na.rm = FALSE,
suppress.warnings.lavaan = FALSE,
suppress.warnings.match = FALSE,
rcs = FALSE,
rcs.choose = NULL,
rcs.res.cov.xz = rcs,
rcs.mc.reps = 1e+05,
rcs.scale.corrected = TRUE,
LAVFUN = lavaan::sem,
...
)modsem object
lavaan syntax
dataframe
method to use:
"dblcent"double centering approach (passed to lavaan).
"ca"constrained approach (passed to lavaan).
"rca"residual centering approach (passed to lavaan).
"uca"unconstrained approach (passed to lavaan).
"pind"prod ind approach, with no constraints or centering (passed to lavaan).
should the product indicators be created by using the match-strategy
should the indicators be recycled when using the match-strategy? I.e., if one of the latent variables have fewer indicators than the other, some indicators are recycled to match the latent variable with the most indicators.
should data be scaled before fitting model
should data be centered before fitting model
Should the first factor loading in the latent product be fixed to one? Defaults to FALSE, as
this already happens in lavaan by default. If TRUE, the first factor loading in the latent product is fixed to one.
Manually in the generated syntax (e.g., XZ =~ 1*x1z1).'
should indicators in products be centered before computing products.
should indicator products be centered after they have been computed?
should indicator products be centered using residuals.
should syntax for residual covariances be produced.
should syntax for product mean be produced.
should syntax for constrained loadings be produced.
should syntax for constrained variances be produced.
method for constraining residual covariances. Options are
Residuals of product indicators with variables in common are allowed to covary freely. Defualt for most approches.
Residual covariances of product indicators are constrained according to the constrained approach.
Residuals of product indicators with variables in common are constrained to have equal covariances".
Can be useful for models where the model is unidentifiable using res.cov.method == "simple",
(e.g., when there is an interaction between an observed and a latent variable).
Residual covariances between product indicators are not specificed (i.e., constrained to zero).
Produces the same results as constrained.cov.syntax = FALSE.
Can be useful for models where the model is unidentifiable using res.cov.method == "simple",
(e.g., when there is an interaction between an observed and a latent variable).
Should residual covariances be specified/freed across different interaction terms.
For example if you have two interaction terms X:Z and X:W the residuals of the
generated product indicators x1:z1 and x1:w1 may be correlated. If TRUE
residual covariances are allowed across different latent interaction terms. If FALSE
residual covariances are only allowed between product indicators which belong to the same
latent interaction term.
Should residual covariance syntax be generated for interaction
terms that are fully composite (i.e., all component variables defined with <~)?
Defaults to FALSE because for fully composite interaction terms the residual
covariances of the product indicators are not needed. Set to TRUE to force
residual covariance syntax for composite interaction terms (useful for testing).
methods which should be scaled automatically (usually not useful)
methods which should be centered automatically (usually not useful)
estimator to use in lavaan
group variable for multigroup analysis
cluster variable for multilevel models
should the model be run via lavaan, if FALSE only modified syntax and data is returned
should missing values be removed (case-wise)? Defaults to FALSE. If TRUE, missing values are removed case-wise.
If FALSE they are not removed.
should warnings from lavaan be suppressed?
should warnings from match be suppressed?
Should latent variable indicators be replaced with reliability-corrected
single item indicators instead? See relcorr_single_item.
Which latent variables should get their indicators replaced with
reliability-corrected single items? It is passed to relcorr_single_item
as the choose argument.
Should the residual (co-)variances of the product indicators
created from the reliability-corrected single items (created if rcs = TRUE)
be specified and constrained before estimating the model? If TRUE the estimates
for the constraints are approximated using a monte carlo simulation (see the rcs.mc.reps argument).
If FALSE the residual variances are not specified, which usually mean that all
are constrained to zero.
Sample size used in monte-carlo simulation, when approximating the
the estimates of the residual (co-)variances between the product indicators formed
by reliabiliyt-corrected single items (see the rcs.res.cov.xz argument).
Should reliability corrected items be scale-corrected? If TRUE
reliability-corrected single items are corrected for differences in factor loadings between
the items. Default is TRUE.
Function used to estimate the model. Defaults to lavaan::sem.
arguments passed to LAVFUN
library(modsem)
# For more examples, check README and/or GitHub.
# One interaction
m1 <- '
# Outer Model
X =~ x1 + x2 +x3
Y =~ y1 + y2 + y3
Z =~ z1 + z2 + z3
# Inner model
Y ~ X + Z + X:Z
'
# Double centering approach
est <- modsem_pi(m1, oneInt)
summary(est)
if (FALSE) {
# The Constrained Approach
est_ca <- modsem_pi(m1, oneInt, method = "ca")
summary(est_ca)
}
# Theory Of Planned Behavior
tpb <- '
# Outer Model (Based on Hagger et al., 2007)
ATT =~ att1 + att2 + att3 + att4 + att5
SN =~ sn1 + sn2
PBC =~ pbc1 + pbc2 + pbc3
INT =~ int1 + int2 + int3
BEH =~ b1 + b2
# Inner Model (Based on Steinmetz et al., 2011)
# Covariances
ATT ~~ SN + PBC
PBC ~~ SN
# Causal Relationships
INT ~ ATT + SN + PBC
BEH ~ INT + PBC
BEH ~ INT:PBC
'
# Double centering approach
est_tpb <- modsem_pi(tpb, data = TPB)
summary(est_tpb)
if (FALSE) {
# The Constrained Approach
est_tpb_ca <- modsem_pi(tpb, data = TPB, method = "ca")
summary(est_tpb_ca)
}
Run the code above in your browser using DataLab