library(modsem)
7 quadratic effects
In essence quadratic effects are just a special case of interaction effects – where a variable has an interaction effect with itself. Thus, all of the modsem methods can be used to estimate quadratic effects as well.
Here you can see a very 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
'
<- modsem(m1, data = oneInt, method = "lms")
est_lms summary(est_lms)
#> Estimating null model
#> EM: Iteration = 1, LogLik = -17831.87, Change = -17831.875
#> EM: Iteration = 2, LogLik = -17831.87, Change = 0.000
#>
#> modsem (version 1.0.1):
#> Estimator LMS
#> Optimization method EM-NLMINB
#> Number of observations 2000
#> Number of iterations 177
#> Loglikelihood -14687.57
#> Akaike (AIC) 29439.14
#> Bayesian (BIC) 29618.37
#>
#> 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.30
#> Difference test (D) 6288.61
#> 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 Pr(>|z|)
#> X =~
#> x1 1.000
#> x2 0.804 0.013 63.01 0.000
#> x3 0.915 0.014 66.27 0.000
#> Z =~
#> z1 1.000
#> z2 0.810 0.012 66.17 0.000
#> z3 0.881 0.013 68.33 0.000
#> Y =~
#> y1 1.000
#> y2 0.798 0.008 105.68 0.000
#> y3 0.899 0.008 110.34 0.000
#>
#> Regressions:
#> Estimate Std.Error z.value Pr(>|z|)
#> Y ~
#> X 0.672 0.031 21.50 0.000
#> Z 0.569 0.029 19.91 0.000
#> X:X -0.006 0.021 -0.29 0.772
#> X:Z 0.715 0.029 24.65 0.000
#>
#> Intercepts:
#> Estimate Std.Error z.value Pr(>|z|)
#> x1 1.021 0.019 52.87 0.000
#> x2 1.214 0.017 73.50 0.000
#> x3 0.918 0.018 50.39 0.000
#> z1 1.011 0.024 41.99 0.000
#> z2 1.205 0.020 60.16 0.000
#> z3 0.915 0.021 42.57 0.000
#> y1 1.042 0.036 29.21 0.000
#> y2 1.224 0.029 42.23 0.000
#> y3 0.958 0.032 29.63 0.000
#> Y 0.000
#>
#> Covariances:
#> Estimate Std.Error z.value Pr(>|z|)
#> X ~~
#> Z 0.199 0.024 8.39 0.000
#>
#> Variances:
#> Estimate Std.Error z.value Pr(>|z|)
#> x1 0.160 0.008 18.89 0.000
#> x2 0.163 0.007 23.86 0.000
#> x3 0.165 0.008 21.06 0.000
#> z1 0.167 0.009 18.50 0.000
#> z2 0.160 0.007 23.07 0.000
#> z3 0.158 0.007 21.19 0.000
#> y1 0.160 0.009 17.92 0.000
#> y2 0.154 0.007 23.03 0.000
#> y3 0.164 0.008 20.57 0.000
#> X 0.972 0.016 60.08 0.000
#> Z 1.017 0.018 55.49 0.000
#> Y 0.983 0.038 26.13 0.000
In this example we have a simple model with two quadratic effects and one interaction effect, using the QML- and double centering approach, using the data from a subset of the PISA 2006 data.
<- '
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
'
<- modsem(m2, data = jordan)
est_dblcent <- modsem(m2, data = jordan, method = "qml")
est_qml summary(est_qml)
#> Estimating null model
#> Starting M-step
#>
#> modsem (version 1.0.1):
#> Estimator QML
#> Optimization method NLMINB
#> Number of observations 6038
#> Number of iterations 100
#> Loglikelihood -110520.22
#> Akaike (AIC) 221142.45
#> Bayesian (BIC) 221484.44
#>
#> 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.07
#> 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 Pr(>|z|)
#> ENJ =~
#> enjoy1 1.000
#> enjoy2 1.002 0.020 50.588 0.000
#> enjoy3 0.894 0.020 43.671 0.000
#> enjoy4 0.999 0.021 48.230 0.000
#> enjoy5 1.047 0.021 50.403 0.000
#> SC =~
#> academic1 1.000
#> academic2 1.104 0.028 38.951 0.000
#> academic3 1.235 0.030 41.727 0.000
#> academic4 1.254 0.030 41.835 0.000
#> academic5 1.113 0.029 38.653 0.000
#> academic6 1.198 0.030 40.363 0.000
#> CAREER =~
#> career1 1.000
#> career2 1.040 0.016 65.180 0.000
#> career3 0.952 0.016 57.838 0.000
#> career4 0.818 0.017 48.358 0.000
#>
#> Regressions:
#> Estimate Std.Error z.value Pr(>|z|)
#> CAREER ~
#> ENJ 0.523 0.020 26.281 0.000
#> SC 0.467 0.024 19.866 0.000
#> ENJ:ENJ 0.026 0.022 1.205 0.228
#> ENJ:SC -0.039 0.046 -0.850 0.395
#> SC:SC -0.002 0.035 -0.057 0.954
#>
#> Intercepts:
#> Estimate Std.Error z.value Pr(>|z|)
#> enjoy1 0.000 0.014 -0.007 0.994
#> enjoy2 0.000 0.014 0.010 0.992
#> enjoy3 0.000 0.014 -0.021 0.983
#> enjoy4 0.000 0.015 0.007 0.994
#> enjoy5 0.000 0.014 0.025 0.980
#> academic1 0.000 0.011 -0.012 0.991
#> academic2 0.000 0.012 -0.009 0.993
#> academic3 0.000 0.012 -0.036 0.971
#> academic4 0.000 0.012 -0.020 0.984
#> academic5 -0.001 0.012 -0.054 0.957
#> academic6 0.001 0.012 0.059 0.953
#> career1 -0.004 0.017 -0.213 0.831
#> career2 -0.004 0.017 -0.258 0.796
#> career3 -0.004 0.017 -0.222 0.825
#> career4 -0.004 0.016 -0.240 0.811
#> CAREER 0.000
#>
#> Covariances:
#> Estimate Std.Error z.value Pr(>|z|)
#> ENJ ~~
#> SC 0.218 0.009 25.479 0.000
#>
#> Variances:
#> Estimate Std.Error z.value Pr(>|z|)
#> enjoy1 0.487 0.011 44.335 0.000
#> enjoy2 0.488 0.011 44.406 0.000
#> enjoy3 0.596 0.012 48.232 0.000
#> enjoy4 0.488 0.011 44.562 0.000
#> enjoy5 0.442 0.010 42.471 0.000
#> academic1 0.645 0.013 49.814 0.000
#> academic2 0.566 0.012 47.863 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.695 0.000
#> academic6 0.502 0.011 45.434 0.000
#> career1 0.373 0.009 40.393 0.000
#> career2 0.328 0.009 37.018 0.000
#> career3 0.436 0.010 43.272 0.000
#> career4 0.576 0.012 48.373 0.000
#> ENJ 0.500 0.017 29.550 0.000
#> SC 0.338 0.015 23.201 0.000
#> CAREER 0.302 0.010 29.710 0.000
Note: The other approaches work as well, but might be quite slow depending on the number of interaction effects (particularly for the LMS- and constrained approach).