modsem
modsem
is
an R
-package for estimating interaction (i.e., moderation)
effects between latent variables in structural equation models (SEMs).
See https://www.modsem.org for a tutorial.
modsem
is available on CRAN
and
GitHub
, and can be installed as follows:
# From CRAN
install.packages("modsem")
# Latest version from GitHub
install.packages("devtools")
::install_github("kss2k/modsem", build_vignettes = TRUE) devtools
Note: The package needs to be compiled from source
on macOS
and Linux
. If you have issues
installing the package on macOS
, you might need to install
the gfortran
compiler. A C++
compiler is also
required, but should be installed by default on most systems. See the R for macOs page
for more information.
There are a number of approaches for estimating interaction effects
in SEM. In modsem()
, the method = "method"
argument allows you to choose which to use. Different approaches can be
categorized into two groups: Product Indicator (PI) and Distribution
Analytic (DA) approaches.
"ca"
= constrained approach (Algina & Moulder,
2001)
"uca"
= unconstrained approach (Marsh, 2004)"rca"
= residual centering approach (Little et al.,
2006)"dblcent"
= double centering approach (Marsh., 2013)
"pind"
= basic product indicator approach (not
recommended)"lms"
= The Latent Moderated Structural equations (LMS)
approach, see the vignette"qml"
= The Quasi Maximum Likelihood (QML) approach,
see the vignette"mplus"
library(modsem)
<- '
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
<- modsem(m1, oneInt)
est1_dca summary(est1_dca)
# Constrained approach
<- modsem(m1, oneInt, method = "ca")
est1_ca summary(est1_ca)
# QML approach
<- modsem(m1, oneInt, method = "qml")
est1_qml summary(est1_qml, standardized = TRUE)
# LMS approach
<- modsem(m1, oneInt, method = "lms")
est1_lms summary(est1_lms)
<- "
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)
INT ~ ATT + SN + PBC
BEH ~ INT + PBC
BEH ~ PBC:INT
"
# double centering approach
<- modsem(tpb, data = TPB, method = "dblcent")
est_tpb_dca summary(est_tpb_dca)
# Constrained approach using Wrigths path tracing rules for generating
# the appropriate constraints
<- modsem(tpb, data = TPB, method = "ca")
est_tpb_ca summary(est_tpb_ca)
# LMS approach
<- modsem(tpb, data = TPB, method = "lms")
est_tpb_lms summary(est_tpb_lms, standardized = TRUE)
# QML approach
<- modsem(tpb, data = TPB, method = "qml")
est_tpb_qml summary(est_tpb_qml, standardized = TRUE)
<- modsem('y1 ~ x1 + z1 + x1:z1', data = oneInt, method = "pind")
est2 summary(est2)
<- '
m3 # Outer Model
X =~ x1 + x2 +x3
Y =~ y1 + y2 + y3
# Inner model
Y ~ X + z1 + X:z1
'
<- modsem(m3, oneInt, method = "pind")
est3 summary(est3)