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.4):
#>   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.015   52.327    0.000
#>     x3               0.915      0.014   63.559    0.000
#>   Z =~ 
#>     z1               1.000                             
#>     z2               0.810      0.014   59.634    0.000
#>     z3               0.881      0.014   61.614    0.000
#>   Y =~ 
#>     y1               1.000                             
#>     y2               0.798      0.012   66.606    0.000
#>     y3               0.899      0.008  108.526    0.000
#> 
#> Regressions:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   Y ~ 
#>     X                0.672      0.040   16.768    0.000
#>     Z                0.569      0.030   19.134    0.000
#>     X:X             -0.007      0.026   -0.249    0.803
#>     X:Z              0.715      0.034   21.210    0.000
#> 
#> Intercepts:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     x1               1.022      0.023   44.828    0.000
#>     x2               1.215      0.021   57.737    0.000
#>     x3               0.919      0.020   45.714    0.000
#>     z1               1.012      0.033   30.780    0.000
#>     z2               1.206      0.027   44.861    0.000
#>     z3               0.916      0.030   30.400    0.000
#>     y1               1.044      0.041   25.480    0.000
#>     y2               1.225      0.030   41.401    0.000
#>     y3               0.960      0.037   25.942    0.000
#>     Y                0.000                             
#>     X                0.000                             
#>     Z                0.000                             
#> 
#> Covariances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   X ~~ 
#>     Z                0.199      0.029    6.931    0.000
#> 
#> Variances:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     x1               0.160      0.008   18.897    0.000
#>     x2               0.163      0.008   21.142    0.000
#>     x3               0.165      0.008   20.508    0.000
#>     z1               0.167      0.012   14.015    0.000
#>     z2               0.160      0.009   16.948    0.000
#>     z3               0.158      0.009   18.302    0.000
#>     y1               0.160      0.010   15.274    0.000
#>     y2               0.154      0.007   20.884    0.000
#>     y3               0.163      0.008   19.504    0.000
#>     X                0.972      0.042   23.289    0.000
#>     Z                1.017      0.049   20.703    0.000
#>     Y                0.983      0.047   20.796    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.4):
#>   Estimator                                         QML
#>   Optimization method                            NLMINB
#>   Number of observations                           6038
#>   Number of iterations                               86
#>   Loglikelihood                              -110520.22
#>   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.512
#> R-Squared Null-Model (H0):
#>   CAREER                                          0.510
#> R-Squared Change:
#>   CAREER                                          0.002
#> 
#> 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.584    0.000
#>     enjoy3           0.894      0.020   43.669    0.000
#>     enjoy4           0.999      0.021   48.225    0.000
#>     enjoy5           1.047      0.021   50.399    0.000
#>   SC =~ 
#>     academic1        1.000                             
#>     academic2        1.104      0.028   38.946    0.000
#>     academic3        1.235      0.030   41.720    0.000
#>     academic4        1.254      0.030   41.829    0.000
#>     academic5        1.113      0.029   38.649    0.000
#>     academic6        1.198      0.030   40.357    0.000
#>   CAREER =~ 
#>     career1          1.000                             
#>     career2          1.040      0.016   65.181    0.000
#>     career3          0.952      0.016   57.839    0.000
#>     career4          0.818      0.017   48.358    0.000
#> 
#> Regressions:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>   CAREER ~ 
#>     ENJ              0.523      0.020   26.293    0.000
#>     SC               0.467      0.023   19.899    0.000
#>     ENJ:ENJ          0.026      0.022    1.221    0.222
#>     ENJ:SC          -0.040      0.046   -0.874    0.382
#>     SC:SC           -0.002      0.034   -0.049    0.961
#> 
#> Intercepts:
#>                   Estimate  Std.Error  z.value  P(>|z|)
#>     enjoy1           0.000                             
#>     enjoy2           0.000      0.005    0.032    0.975
#>     enjoy3           0.000      0.009   -0.035    0.972
#>     enjoy4           0.000                             
#>     enjoy5           0.000      0.006    0.059    0.953
#>     academic1        0.000      0.007   -0.016    0.988
#>     academic2        0.000      0.011   -0.014    0.989
#>     academic3        0.000      0.011   -0.039    0.969
#>     academic4        0.000      0.010   -0.022    0.983
#>     academic5       -0.001      0.011   -0.061    0.951
#>     academic6        0.001      0.011    0.064    0.949
#>     career1         -0.004      0.015   -0.246    0.806
#>     career2         -0.005      0.015   -0.299    0.765
#>     career3         -0.004      0.015   -0.255    0.798
#>     career4         -0.004      0.014   -0.269    0.788
#>     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.332    0.000
#>     enjoy2           0.488      0.011   44.407    0.000
#>     enjoy3           0.596      0.012   48.234    0.000
#>     enjoy4           0.488      0.011   44.561    0.000
#>     enjoy5           0.442      0.010   42.472    0.000
#>     academic1        0.644      0.013   49.816    0.000
#>     academic2        0.566      0.012   47.862    0.000
#>     academic3        0.474      0.011   44.316    0.000
#>     academic4        0.455      0.010   43.580    0.000
#>     academic5        0.565      0.012   47.696    0.000
#>     academic6        0.502      0.011   45.434    0.000
#>     career1          0.373      0.009   40.392    0.000
#>     career2          0.328      0.009   37.018    0.000
#>     career3          0.436      0.010   43.274    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.196    0.000
#>     CAREER           0.302      0.010   29.710    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.