Package: modsem 1.0.6
modsem: Latent Interaction (and Moderation) Analysis in Structural Equation Models (SEM)
Estimation of interaction (i.e., moderation) effects between latent variables in structural equation models (SEM). The supported methods are: The constrained approach (Algina & Moulder, 2001). The unconstrained approach (Marsh et al., 2004). The residual centering approach (Little et al., 2006). The double centering approach (Lin et al., 2010). The latent moderated structural equations (LMS) approach (Klein & Moosbrugger, 2000). The quasi-maximum likelihood (QML) approach (Klein & Muthén, 2007) (temporarily unavailable) The constrained- unconstrained, residual- and double centering- approaches are estimated via 'lavaan' (Rosseel, 2012), whilst the LMS- and QML- approaches are estimated via 'modsem' it self. Alternatively model can be estimated via 'Mplus' (Muthén & Muthén, 1998-2017). References: Algina, J., & Moulder, B. C. (2001). <doi:10.1207/S15328007SEM0801_3>. "A note on estimating the Jöreskog-Yang model for latent variable interaction using 'LISREL' 8.3." Klein, A., & Moosbrugger, H. (2000). <doi:10.1007/BF02296338>. "Maximum likelihood estimation of latent interaction effects with the LMS method." Klein, A. G., & Muthén, B. O. (2007). <doi:10.1080/00273170701710205>. "Quasi-maximum likelihood estimation of structural equation models with multiple interaction and quadratic effects." Lin, G. C., Wen, Z., Marsh, H. W., & Lin, H. S. (2010). <doi:10.1080/10705511.2010.488999>. "Structural equation models of latent interactions: Clarification of orthogonalizing and double-mean-centering strategies." Little, T. D., Bovaird, J. A., & Widaman, K. F. (2006). <doi:10.1207/s15328007sem1304_1>. "On the merits of orthogonalizing powered and product terms: Implications for modeling interactions among latent variables." Marsh, H. W., Wen, Z., & Hau, K. T. (2004). <doi:10.1037/1082-989X.9.3.275>. "Structural equation models of latent interactions: evaluation of alternative estimation strategies and indicator construction." Muthén, L.K. and Muthén, B.O. (1998-2017). "'Mplus' User’s Guide. Eighth Edition." <https://www.statmodel.com/>. Rosseel Y (2012). <doi:10.18637/jss.v048.i02>. "'lavaan': An R Package for Structural Equation Modeling."
Authors:
modsem_1.0.6.tar.gz
modsem_1.0.6.zip(r-4.5)modsem_1.0.6.zip(r-4.4)modsem_1.0.6.zip(r-4.3)
modsem_1.0.6.tgz(r-4.5-x86_64)modsem_1.0.6.tgz(r-4.5-arm64)modsem_1.0.6.tgz(r-4.4-x86_64)modsem_1.0.6.tgz(r-4.4-arm64)modsem_1.0.6.tgz(r-4.3-x86_64)modsem_1.0.6.tgz(r-4.3-arm64)
modsem_1.0.6.tar.gz(r-4.5-noble)modsem_1.0.6.tar.gz(r-4.4-noble)
modsem_1.0.6.tgz(r-4.4-emscripten)modsem_1.0.6.tgz(r-4.3-emscripten)
modsem.pdf |modsem.html✨
modsem/json (API)
# Install 'modsem' in R: |
install.packages('modsem', repos = c('https://kss2k.r-universe.dev', 'https://cloud.r-project.org')) |
Bug tracker:https://github.com/kss2k/modsem/issues0 issues
Pkgdown site:https://modsem.org
On CRAN:modsem-1.0.6(2025-01-20)
interaction-effectinteraction-effectslatent-moderated-structural-equationslavaan-syntaxlmsmoderationqmlquasi-maximum-likelihoodrlangrlanguagesemstructural-equation-modelingstructural-equation-modelsopenblascppopenmp
Last updated 15 days agofrom:b853fe2bed. Checks:7 OK, 4 NOTE. Indexed: yes.
Target | Result | Latest binary |
---|---|---|
Doc / Vignettes | OK | Feb 19 2025 |
R-4.5-win-x86_64 | NOTE | Feb 19 2025 |
R-4.5-mac-x86_64 | NOTE | Feb 19 2025 |
R-4.5-mac-aarch64 | NOTE | Feb 19 2025 |
R-4.5-linux-x86_64 | NOTE | Feb 19 2025 |
R-4.4-win-x86_64 | OK | Feb 19 2025 |
R-4.4-mac-x86_64 | OK | Feb 19 2025 |
R-4.4-mac-aarch64 | OK | Feb 19 2025 |
R-4.3-win-x86_64 | OK | Feb 19 2025 |
R-4.3-mac-x86_64 | OK | Feb 19 2025 |
R-4.3-mac-aarch64 | OK | Feb 19 2025 |
Exports:coef_modsem_dacompare_fitdefault_settings_dadefault_settings_piextract_lavaanfit_modsem_daget_pi_dataget_pi_syntaxmodsemmodsem_damodsem_inspectmodsem_mplusmodsem_pimodsemifymultiplyIndicatorsCppparameter_estimatesplot_interactionplot_jnplot_surfacesimple_slopesstandardized_estimatestrace_pathvar_interactionsvcov_modsem_da
Dependencies:askpassbackportsbase64encBHbootbslibcachemcheckmateclicodacolorspacecpp11crosstalkcurldata.tabledigestdplyrevaluatefansifarverfastDummiesfastGHQuadfastmapfontawesomefsgenericsggplot2gluegsubfngtablehighrhtmltoolshtmlwidgetshttrisobandjquerylibjsonliteknitrlabelinglaterlatticelavaanlazyevallifecyclemagrittrMASSMatrixmemoisemgcvmimemnormtMplusAutomationmunsellmvnfastmvtnormnlmenumDerivopensslpanderpbivnormpillarpkgconfigplotlyplyrpromisesprotopurrrquadprogR6rappdirsRColorBrewerRcppRcppArmadillorlangrmarkdownsassscalesstringistringrsystexregtibbletidyrtidyselecttinytexutf8vctrsviridisLitewithrxfunxtableyaml
customizing interaction terms
Rendered fromcustomizing.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-10-17
Started: 2024-05-31
higher order interactions
Rendered fromhigher_order_interactions.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-11-07
Started: 2024-11-03
interaction effects between endogenous variables
Rendered frominteraction_two_etas.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-10-17
Started: 2024-06-04
LMS and QML approaches
Rendered fromlms_qml.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-11-15
Started: 2024-05-31
methods
Rendered frommethods.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-11-15
Started: 2024-05-31
modsem
Rendered frommodsem.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-10-17
Started: 2024-05-31
observed variables in the LMS- and QML approach
Rendered fromobserved_lms_qml.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-10-17
Started: 2024-06-22
plotting interaction effects
Rendered fromplot_interactions.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2025-01-20
Started: 2024-06-01
quadratic effects
Rendered fromquadratic.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-11-03
Started: 2024-05-31
simple slopes analysis
Rendered fromsimple_slopes.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2025-01-20
Started: 2025-01-07
using lavaan functions
Rendered fromlavaan.Rmd
usingknitr::rmarkdown
on Feb 19 2025.Last update: 2024-07-26
Started: 2024-05-31
Citation
To cite modsem in publications use:
Slupphaug, K. S., Mehmetoglu, M., & Mittner, M. (2024). modsem: An R package for estimating latent interactions and quadratic effects. Structural Equation Modeling: A Multidisciplinary Journal https://doi.org/10.1080/10705511.2024.2417409
Corresponding BibTeX entry:
@Article{, title = {modsem: An R package for estimating latent interactions and quadratic effects}, author = {Kjell Solem Slupphaug and Mehmet Mehmetoglu and Matthias Mittner}, journal = {Structural Equation Modeling: A Multidisciplinary Journal}, year = {2024}, doi = {10.1080/10705511.2024.2417409}, }
Readme and manuals
modsem
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.
To Install
# From CRAN
install.packages("modsem")
# Latest version from GitHub
install.packages("devtools")
devtools::install_github("kss2k/modsem", build_vignettes = TRUE)
Methods/Approaches
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.
Product Indicator (PI) Approaches:
-
"ca"
= constrained approach (Algina & Moulder, 2001)- Note that constraints can become quite complicated for complex models, particularly when there is an interaction including enodgenous variables. The method can therefore be quite slow.
-
"uca"
= unconstrained approach (Marsh, 2004) -
"rca"
= residual centering approach (Little et al., 2006) -
"dblcent"
= double centering approach (Marsh., 2013)- default
-
"pind"
= basic product indicator approach (not recommended)
Distribution Analytic (DA) Approaches
-
"lms"
= The Latent Moderated Structural equations (LMS) approach, see the vignette -
"qml"
= The Quasi Maximum Likelihood (QML) approach, see the vignette -
"mplus"
- estimates model through Mplus, if it is installed
Examples
Elementary Interaction Model (Kenny & Judd, 1984; Jaccard & Wan, 1995)
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
est1_dca <- modsem(m1, oneInt)
summary(est1_dca)
# Constrained approach
est1_ca <- modsem(m1, oneInt, method = "ca")
summary(est1_ca)
# QML approach
est1_qml <- modsem(m1, oneInt, method = "qml")
summary(est1_qml, standardized = TRUE)
# LMS approach
est1_lms <- modsem(m1, oneInt, method = "lms")
summary(est1_lms)
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)
INT ~ ATT + SN + PBC
BEH ~ INT + PBC
BEH ~ PBC:INT
"
# double centering approach
est_tpb_dca <- modsem(tpb, data = TPB, method = "dblcent")
summary(est_tpb_dca)
# Constrained approach using Wrigths path tracing rules for generating
# the appropriate constraints
est_tpb_ca <- modsem(tpb, data = TPB, method = "ca")
summary(est_tpb_ca)
# LMS approach
est_tpb_lms <- modsem(tpb, data = TPB, method = "lms")
summary(est_tpb_lms, standardized = TRUE)
# QML approach
est_tpb_qml <- modsem(tpb, data = TPB, method = "qml")
summary(est_tpb_qml, standardized = TRUE)
Interactions between two observed variables
est2 <- modsem('y1 ~ x1 + z1 + x1:z1', data = oneInt, method = "pind")
summary(est2)
Interaction between an obsereved and a latent variable
m3 <- '
# Outer Model
X =~ x1 + x2 +x3
Y =~ y1 + y2 + y3
# Inner model
Y ~ X + z1 + X:z1
'
est3 <- modsem(m3, oneInt, method = "pind")
summary(est3)