EVAL_DEFAULT <- FALSE knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = EVAL_DEFAULT )
library(modsem)
Quadratic effects are essentially a special case of interaction effects—where a variable interacts with itself. As such, all of the methods in modsem
can also be used to estimate quadratic effects.
Below is a simple example using the LMS
approach.
library(modsem) m1 <- ' # Outer Model X =~ x1 + x2 + x3 Y =~ y1 + y2 + y3 Z =~ z1 + z2 + z3 # Inner model Y ~ X + Z + Z:X + X:X ' est1Lms <- modsem(m1, data = oneInt, method = "lms") summary(est1Lms)
In this example, we have a simple model with two quadratic effects and one interaction effect. We estimate the model using both the QML
and double-centering approaches, with data from a subset of the PISA 2006 dataset.
m2 <- ' ENJ =~ enjoy1 + enjoy2 + enjoy3 + enjoy4 + enjoy5 CAREER =~ career1 + career2 + career3 + career4 SC =~ academic1 + academic2 + academic3 + academic4 + academic5 + academic6 CAREER ~ ENJ + SC + ENJ:ENJ + SC:SC + ENJ:SC ' est2Dblcent <- modsem(m2, data = jordan) est2Qml <- modsem(m2, data = jordan, method = "qml") summary(est2Qml)
Note: The other approaches (e.g., LMS
and constrained methods) can also be used but may be slower depending on the number of interaction effects, especially for the LMS
and constrained approaches.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.