Skip to contents

Quadratic Effects and Interaction Effects

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)
#> 
#> modsem (version 1.0.8):
#>   Estimator                                         LMS
#>   Optimization method                         EM-NLMINB
#>   Number of observations                           2000
#>   Number of iterations                              115
#>   Loglikelihood                               -14687.59
#>   Akaike (AIC)                                 29439.17
#>   Bayesian (BIC)                                29618.4
#>  
#> Numerical Integration:
#>   Points of integration (per dim)                    24
#>   Dimensions                                          1
#>   Total points of integration                        24
#>  
#> Fit Measures for H0:
#>   Loglikelihood                                  -17832
#>   Akaike (AIC)                                 35723.75
#>   Bayesian (BIC)                               35891.78
#>   Chi-square                                      17.52
#>   Degrees of Freedom (Chi-square)                    24
#>   P-value (Chi-square)                            0.826
#>   RMSEA                                           0.000
#>  
#> Comparative fit to H0 (no interaction effect)
#>   Loglikelihood change                          3144.29
#>   Difference test (D)                           6288.58
#>   Degrees of freedom (D)                              2
#>   P-value (D)                                     0.000
#>  
#> R-Squared:
#>   Y                                               0.595
#> R-Squared Null-Model (H0):
#>   Y                                               0.395
#> R-Squared Change:
#>   Y                                               0.200
#> 
#> Parameter Estimates:
#>   Coefficients                           unstandardized
#>   Information                                  expected
#>   Standard errors                              standard
#>  
#> Latent Variables:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   X =~ 
#>     x1               1.000                             
#>     x2               0.804      0.014   55.948    0.000
#>     x3               0.915      0.016   55.893    0.000
#>   Z =~ 
#>     z1               1.000                             
#>     z2               0.810      0.017   47.672    0.000
#>     z3               0.881      0.016   55.160    0.000
#>   Y =~ 
#>     y1               1.000                             
#>     y2               0.798      0.009   90.080    0.000
#>     y3               0.899      0.011   81.861    0.000
#> 
#> Regressions:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   Y ~ 
#>     X                0.672      0.038   17.528    0.000
#>     Z                0.569      0.033   17.367    0.000
#>     X:X             -0.007      0.024   -0.271    0.787
#>     X:Z              0.715      0.035   20.354    0.000
#> 
#> Intercepts:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     x1               1.022      0.023   44.849    0.000
#>     x2               1.215      0.022   56.299    0.000
#>     x3               0.919      0.022   42.355    0.000
#>     z1               1.012      0.035   28.955    0.000
#>     z2               1.206      0.024   49.720    0.000
#>     z3               0.916      0.029   31.176    0.000
#>     y1               1.044      0.037   28.452    0.000
#>     y2               1.225      0.028   43.895    0.000
#>     y3               0.960      0.036   26.470    0.000
#>     Y                0.000                             
#>     X                0.000                             
#>     Z                0.000                             
#> 
#> Covariances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   X ~~ 
#>     Z                0.199      0.031    6.517    0.000
#> 
#> Variances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     x1               0.160      0.009   17.922    0.000
#>     x2               0.163      0.007   21.806    0.000
#>     x3               0.165      0.009   19.308    0.000
#>     z1               0.167      0.011   15.723    0.000
#>     z2               0.160      0.009   18.506    0.000
#>     z3               0.158      0.010   16.188    0.000
#>     y1               0.160      0.011   14.413    0.000
#>     y2               0.154      0.009   16.941    0.000
#>     y3               0.163      0.010   16.464    0.000
#>     X                0.972      0.041   23.658    0.000
#>     Z                1.017      0.046   22.038    0.000
#>     Y                0.983      0.042   23.366    0.000

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")
#> Warning: SE's for some coefficients could not be computed.
summary(est2Qml)
#> 
#> modsem (version 1.0.8):
#>   Estimator                                         QML
#>   Optimization method                            NLMINB
#>   Number of observations                           6038
#>   Number of iterations                               71
#>   Loglikelihood                              -110520.23
#>   Akaike (AIC)                                221142.45
#>   Bayesian (BIC)                              221484.45
#>  
#> Fit Measures for H0:
#>   Loglikelihood                                 -110521
#>   Akaike (AIC)                                221138.58
#>   Bayesian (BIC)                              221460.46
#>   Chi-square                                    1016.34
#>   Degrees of Freedom (Chi-square)                    87
#>   P-value (Chi-square)                            0.000
#>   RMSEA                                           0.005
#>  
#> Comparative fit to H0 (no interaction effect)
#>   Loglikelihood change                             1.06
#>   Difference test (D)                              2.13
#>   Degrees of freedom (D)                              3
#>   P-value (D)                                     0.546
#>  
#> R-Squared:
#>   CAREER                                          0.513
#> R-Squared Null-Model (H0):
#>   CAREER                                          0.510
#> R-Squared Change:
#>   CAREER                                          0.003
#> 
#> Parameter Estimates:
#>   Coefficients                           unstandardized
#>   Information                                  observed
#>   Standard errors                              standard
#>  
#> Latent Variables:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   ENJ =~ 
#>     enjoy1           1.000                             
#>     enjoy2           1.002      0.020   50.583    0.000
#>     enjoy3           0.894      0.020   43.667    0.000
#>     enjoy4           0.999      0.021   48.224    0.000
#>     enjoy5           1.047      0.021   50.398    0.000
#>   SC =~ 
#>     academic1        1.000                             
#>     academic2        1.104      0.028   38.949    0.000
#>     academic3        1.235      0.030   41.723    0.000
#>     academic4        1.254      0.030   41.832    0.000
#>     academic5        1.113      0.029   38.651    0.000
#>     academic6        1.198      0.030   40.360    0.000
#>   CAREER =~ 
#>     career1          1.000                             
#>     career2          1.040      0.016   65.180    0.000
#>     career3          0.952      0.016   57.839    0.000
#>     career4          0.818      0.017   48.357    0.000
#> 
#> Regressions:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   CAREER ~ 
#>     ENJ              0.524      0.020   26.422    0.000
#>     SC               0.467      0.023   19.886    0.000
#>     ENJ:ENJ          0.027      0.022    1.225    0.220
#>     ENJ:SC          -0.040      0.046   -0.873    0.383
#>     SC:SC           -0.001      0.035   -0.043    0.966
#> 
#> Intercepts:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     enjoy1           0.000                             
#>     enjoy2           0.000                             
#>     enjoy3           0.000                             
#>     enjoy4           0.000                             
#>     enjoy5           0.000                             
#>     academic1        0.000      0.012   -0.011    0.991
#>     academic2        0.000                             
#>     academic3        0.000      0.011   -0.039    0.969
#>     academic4        0.000      0.009   -0.027    0.979
#>     academic5       -0.001      0.011   -0.056    0.955
#>     academic6        0.001      0.008    0.086    0.931
#>     career1         -0.004                             
#>     career2         -0.005                             
#>     career3         -0.004                             
#>     career4         -0.004      0.006   -0.643    0.520
#>     CAREER           0.000                             
#>     ENJ              0.000                             
#>     SC               0.000                             
#> 
#> Covariances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   ENJ ~~ 
#>     SC               0.218      0.009   25.477    0.000
#> 
#> Variances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     enjoy1           0.487      0.011   44.335    0.000
#>     enjoy2           0.488      0.011   44.404    0.000
#>     enjoy3           0.596      0.012   48.232    0.000
#>     enjoy4           0.488      0.011   44.561    0.000
#>     enjoy5           0.442      0.010   42.470    0.000
#>     academic1        0.645      0.013   49.812    0.000
#>     academic2        0.566      0.012   47.864    0.000
#>     academic3        0.473      0.011   44.318    0.000
#>     academic4        0.455      0.010   43.579    0.000
#>     academic5        0.565      0.012   47.696    0.000
#>     academic6        0.502      0.011   45.435    0.000
#>     career1          0.373      0.009   40.391    0.000
#>     career2          0.328      0.009   37.018    0.000
#>     career3          0.436      0.010   43.271    0.000
#>     career4          0.576      0.012   48.373    0.000
#>     ENJ              0.500      0.017   29.546    0.000
#>     SC               0.338      0.015   23.198    0.000
#>     CAREER           0.302      0.010   29.712    0.000

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.