Skip to contents
library(modsem)
#> This is modsem (1.0.22). Please report any bugs!

Non-centered interaction terms

Using the LMS and QML approaches it is possible to estimate interaction terms where the means of the latent variables are not centered (i.e., they have non-zero means).

Here we can see an example using the TPB dataset:

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 ~ INT:PBC

# Adding Latent Intercepts
  INT ~ 1
  BEH ~ 1
  PBC ~ 1
  SN  ~ 1
  ATT ~ 1
'

est <- modsem(tpb, TPB, method = "lms", nodes = 32)
summary(est)
#> 
#> modsem (1.0.22) ended normally after 53 iterations
#> 
#>   Estimator                                        LMS
#>   Optimization method                       EMA-NLMINB
#>   Number of model parameters                        54
#> 
#>   Number of observations                          2000
#> 
#> Loglikelihood and Information Criteria:
#>   Loglikelihood                              -26326.02
#>   Akaike (AIC)                                52760.04
#>   Bayesian (BIC)                              53062.49
#>  
#> Numerical Integration:
#>   Points of integration (per dim)                   32
#>   Dimensions                                         1
#>   Total points of integration                       32
#> 
#> Fit Measures for Baseline Model (H0):
#>                                               Standard
#>   Chi-square                                     66.27
#>   Degrees of Freedom (Chi-square)                   82
#>   P-value (Chi-square)                           0.897
#>   RMSEA                                          0.000
#>                                                       
#>   Loglikelihood                              -26393.22
#>   Akaike (AIC)                                52892.45
#>   Bayesian (BIC)                              53189.29
#>  
#> Comparative Fit to H0 (LRT test):
#>   Loglikelihood change                           67.20
#>   Difference test (D)                           134.41
#>   Degrees of freedom (D)                             1
#>   P-value (D)                                    0.000
#>  
#> R-Squared Interaction Model (H1):
#>   INT                                            0.366
#>   BEH                                            0.263
#> R-Squared Baseline Model (H0):
#>   INT                                            0.367
#>   BEH                                            0.210
#> R-Squared Change (H1 - H0):
#>   INT                                            0.000
#>   BEH                                            0.053
#> 
#> Parameter Estimates:
#>   Coefficients                          unstandardized
#>   Information                                 observed
#>   Standard errors                             standard
#>  
#> Latent Variables:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   ATT =~        
#>     att1            1.000                             
#>     att2            0.878      0.012   71.496    0.000
#>     att3            0.789      0.012   66.323    0.000
#>     att4            0.695      0.011   60.960    0.000
#>     att5            0.887      0.013   70.786    0.000
#>   SN =~         
#>     sn1             1.000                             
#>     sn2             0.888      0.017   52.442    0.000
#>   PBC =~        
#>     pbc1            1.000                             
#>     pbc2            0.912      0.013   69.248    0.000
#>     pbc3            0.801      0.012   65.950    0.000
#>   INT =~        
#>     int1            1.000                             
#>     int2            0.913      0.015   58.974    0.000
#>     int3            0.807      0.014   55.678    0.000
#>   BEH =~        
#>     b1              1.000                             
#>     b2              0.960      0.031   31.459    0.000
#> 
#> Regressions:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   INT ~         
#>     ATT             0.213      0.026    8.163    0.000
#>     SN              0.176      0.028    6.385    0.000
#>     PBC             0.217      0.030    7.349    0.000
#>   BEH ~         
#>     PBC             0.025      0.029    0.866    0.386
#>     INT            -0.015      0.030   -0.499    0.618
#>     INT:PBC         0.205      0.018   11.299    0.000
#> 
#> Intercepts:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>    .pbc2            0.075      0.018    4.226    0.000
#>    .pbc3            0.192      0.016   11.707    0.000
#>    .att2            0.117      0.017    6.817    0.000
#>    .att3            0.217      0.017   13.020    0.000
#>    .att4            0.294      0.016   18.438    0.000
#>    .att5            0.093      0.018    5.310    0.000
#>    .sn2             0.117      0.021    5.592    0.000
#>    .int2            0.087      0.020    4.373    0.000
#>    .int3            0.187      0.019    9.978    0.000
#>    .b2              0.058      0.036    1.615    0.106
#>     ATT             1.014      0.024   41.991    0.000
#>     SN              1.005      0.024   41.644    0.000
#>     PBC             0.997      0.024   42.397    0.000
#>    .INT             0.403      0.027   14.693    0.000
#>    .BEH             0.784      0.030   26.187    0.000
#> 
#> Covariances:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   ATT ~~        
#>     SN              0.629      0.029   21.934    0.000
#>   PBC ~~        
#>     ATT             0.678      0.029   23.709    0.000
#>     SN              0.678      0.029   23.328    0.000
#> 
#> Variances:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>    .pbc1            0.144      0.008   18.093    0.000
#>    .pbc2            0.160      0.008   21.184    0.000
#>    .pbc3            0.155      0.007   23.675    0.000
#>    .att1            0.167      0.007   23.449    0.000
#>    .att2            0.150      0.006   24.613    0.000
#>    .att3            0.160      0.006   26.274    0.000
#>    .att4            0.162      0.006   27.534    0.000
#>    .att5            0.159      0.006   24.829    0.000
#>    .sn1             0.178      0.015   12.026    0.000
#>    .sn2             0.157      0.012   13.180    0.000
#>    .int1            0.157      0.009   18.042    0.000
#>    .int2            0.160      0.008   20.330    0.000
#>    .int3            0.168      0.007   23.461    0.000
#>    .b1              0.186      0.019   10.017    0.000
#>    .b2              0.135      0.017    8.041    0.000
#>     ATT             0.998      0.037   27.109    0.000
#>     SN              0.988      0.039   25.371    0.000
#>     PBC             0.963      0.035   27.237    0.000
#>    .INT             0.491      0.020   24.595    0.000
#>    .BEH             0.455      0.023   20.027    0.000

Comparing this to the estimates we get when PBC and INT have zero means, we see that the coefficients BEH~PBC and BEH~INT are drastically changed. This is not a bug, and is a function of the interaction effect rescaling the coefficients, when not centered at zero. When using the standardized_estimates function, or summary(est, standardized = TRUE) the interaction effect is centered, and we can see that the coefficients BEH~PBC and BEH~INT are rescaled once again.

summary(est, standardized = TRUE, centered = TRUE)
#> 
#> modsem (1.0.22) ended normally after 53 iterations
#> 
#>   Estimator                                        LMS
#>   Optimization method                       EMA-NLMINB
#>   Number of model parameters                        54
#> 
#>   Number of observations                          2000
#> 
#> Loglikelihood and Information Criteria:
#>   Loglikelihood                              -26326.02
#>   Akaike (AIC)                                52760.04
#>   Bayesian (BIC)                              53062.49
#>  
#> Numerical Integration:
#>   Points of integration (per dim)                   32
#>   Dimensions                                         1
#>   Total points of integration                       32
#> 
#> Fit Measures for Baseline Model (H0):
#>                                               Standard
#>   Chi-square                                     66.27
#>   Degrees of Freedom (Chi-square)                   82
#>   P-value (Chi-square)                           0.897
#>   RMSEA                                          0.000
#>                                                       
#>   Loglikelihood                              -26393.22
#>   Akaike (AIC)                                52892.45
#>   Bayesian (BIC)                              53189.29
#>  
#> Comparative Fit to H0 (LRT test):
#>   Loglikelihood change                           67.20
#>   Difference test (D)                           134.41
#>   Degrees of freedom (D)                             1
#>   P-value (D)                                    0.000
#>  
#> R-Squared Interaction Model (H1):
#>   INT                                            0.366
#>   BEH                                            0.263
#> R-Squared Baseline Model (H0):
#>   INT                                            0.367
#>   BEH                                            0.210
#> R-Squared Change (H1 - H0):
#>   INT                                            0.000
#>   BEH                                            0.053
#> 
#> Parameter Estimates:
#>   Coefficients                            standardized
#>   Information                                 observed
#>   Standard errors                             standard
#>  
#> Latent Variables:
#>                  Estimate  Std.Error  z.value  P(>|z|)  Std.all  Cnt.all
#>   ATT =~        
#>     att1            1.000                                 0.925    1.000
#>     att2            0.878      0.012   71.496    0.000    0.915    0.878
#>     att3            0.789      0.012   66.323    0.000    0.892    0.789
#>     att4            0.695      0.011   60.960    0.000    0.865    0.695
#>     att5            0.887      0.013   70.786    0.000    0.912    0.887
#>   SN =~         
#>     sn1             1.000                                 0.921    1.000
#>     sn2             0.888      0.017   52.442    0.000    0.913    0.888
#>   PBC =~        
#>     pbc1            1.000                                 0.933    1.000
#>     pbc2            0.912      0.013   69.248    0.000    0.913    0.912
#>     pbc3            0.801      0.012   65.950    0.000    0.894    0.801
#>   INT =~        
#>     int1            1.000                                 0.912    1.000
#>     int2            0.913      0.015   58.974    0.000    0.895    0.913
#>     int3            0.807      0.014   55.678    0.000    0.867    0.807
#>   BEH =~        
#>     b1              1.000                                 0.877    1.000
#>     b2              0.960      0.031   31.459    0.000    0.899    0.960
#> 
#> Regressions:
#>                  Estimate  Std.Error  z.value  P(>|z|)  Std.all  Cnt.all
#>   INT ~         
#>     ATT             0.213      0.026    8.163    0.000    0.242    0.213
#>     SN              0.176      0.028    6.385    0.000    0.199    0.176
#>     PBC             0.217      0.030    7.349    0.000    0.242    0.217
#>   BEH ~         
#>     PBC             0.025      0.029    0.866    0.386    0.290    0.232
#>     INT            -0.015      0.030   -0.499    0.618    0.212    0.189
#>     INT:PBC         0.205      0.018   11.299    0.000    0.225    0.205
#> 
#> Intercepts:
#>                  Estimate  Std.Error  z.value  P(>|z|)  Std.all  Cnt.all
#>    .pbc2            0.075      0.018    4.226    0.000                  
#>    .pbc3            0.192      0.016   11.707    0.000                  
#>    .att2            0.117      0.017    6.817    0.000                  
#>    .att3            0.217      0.017   13.020    0.000                  
#>    .att4            0.294      0.016   18.438    0.000                  
#>    .att5            0.093      0.018    5.310    0.000                  
#>    .sn2             0.117      0.021    5.592    0.000                  
#>    .int2            0.087      0.020    4.373    0.000                  
#>    .int3            0.187      0.019    9.978    0.000                  
#>    .b2              0.058      0.036    1.615    0.106                  
#>     ATT             1.014      0.024   41.991    0.000                  
#>     SN              1.005      0.024   41.644    0.000                  
#>     PBC             0.997      0.024   42.397    0.000                  
#>    .INT             0.403      0.027   14.693    0.000                  
#>    .BEH             0.784      0.030   26.187    0.000                  
#> 
#> Covariances:
#>                  Estimate  Std.Error  z.value  P(>|z|)  Std.all  Cnt.all
#>   ATT ~~        
#>     SN              0.629      0.029   21.934    0.000    0.634    0.629
#>   PBC ~~        
#>     ATT             0.678      0.029   23.709    0.000    0.692    0.678
#>     SN              0.678      0.029   23.328    0.000    0.695    0.678
#> 
#> Variances:
#>                  Estimate  Std.Error  z.value  P(>|z|)  Std.all  Cnt.all
#>    .pbc1            0.144      0.008   18.093    0.000    0.130    0.144
#>    .pbc2            0.160      0.008   21.184    0.000    0.166    0.160
#>    .pbc3            0.155      0.007   23.675    0.000    0.201    0.155
#>    .att1            0.167      0.007   23.449    0.000    0.144    0.167
#>    .att2            0.150      0.006   24.613    0.000    0.164    0.150
#>    .att3            0.160      0.006   26.274    0.000    0.204    0.160
#>    .att4            0.162      0.006   27.534    0.000    0.252    0.162
#>    .att5            0.159      0.006   24.829    0.000    0.168    0.159
#>    .sn1             0.178      0.015   12.026    0.000    0.153    0.178
#>    .sn2             0.157      0.012   13.180    0.000    0.167    0.157
#>    .int1            0.157      0.009   18.042    0.000    0.168    0.157
#>    .int2            0.160      0.008   20.330    0.000    0.199    0.160
#>    .int3            0.168      0.007   23.461    0.000    0.249    0.168
#>    .b1              0.186      0.019   10.017    0.000    0.231    0.186
#>    .b2              0.135      0.017    8.041    0.000    0.192    0.135
#>     ATT             0.998      0.037   27.109    0.000    1.000    0.998
#>     SN              0.988      0.039   25.371    0.000    1.000    0.988
#>     PBC             0.963      0.035   27.237    0.000    1.000    0.963
#>    .INT             0.491      0.020   24.595    0.000    0.634    0.491
#>    .BEH             0.455      0.023   20.027    0.000    0.737    0.455

It is also possible to get the centered solution using the centered_estimates() function. Note, that centered_estimates() removes the mean structure of the model all together.

centered_estimates(est)
#>        lhs op     rhs label group   est std.error z.value p.value ci.lower
#> 1      ATT =~    att1           1 1.000        NA      NA      NA       NA
#> 2      ATT =~    att2           1 0.878     0.012  71.496       0    0.854
#> 3      ATT =~    att3           1 0.789     0.012  66.323       0    0.765
#> 4      ATT =~    att4           1 0.695     0.011  60.960       0    0.672
#> 5      ATT =~    att5           1 0.887     0.013  70.786       0    0.862
#> 6       SN =~     sn1           1 1.000        NA      NA      NA       NA
#> 7       SN =~     sn2           1 0.888     0.017  52.442       0    0.855
#> 8      PBC =~    pbc1           1 1.000        NA      NA      NA       NA
#> 9      PBC =~    pbc2           1 0.912     0.013  69.248       0    0.886
#> 10     PBC =~    pbc3           1 0.801     0.012  65.950       0    0.777
#> 11     INT =~    int1           1 1.000        NA      NA      NA       NA
#> 12     INT =~    int2           1 0.913     0.015  58.974       0    0.883
#> 13     INT =~    int3           1 0.807     0.014  55.678       0    0.779
#> 14     BEH =~      b1           1 1.000        NA      NA      NA       NA
#> 15     BEH =~      b2           1 0.960     0.031  31.459       0    0.901
#> 16     INT  ~     ATT           1 0.213     0.026   8.163       0    0.162
#> 17     INT  ~      SN           1 0.176     0.028   6.385       0    0.122
#> 18     INT  ~     PBC           1 0.217     0.030   7.349       0    0.159
#> 19     BEH  ~     PBC           1 0.232     0.022  10.401       0    0.189
#> 20     BEH  ~     INT           1 0.189     0.025   7.674       0    0.141
#> 21     BEH  ~ INT:PBC           1 0.205     0.018  11.299       0    0.169
#> 22    pbc1 ~~    pbc1           1 0.144     0.008  18.093       0    0.129
#> 23    pbc2 ~~    pbc2           1 0.160     0.008  21.184       0    0.145
#> 24    pbc3 ~~    pbc3           1 0.155     0.007  23.675       0    0.142
#> 25    att1 ~~    att1           1 0.167     0.007  23.449       0    0.153
#> 26    att2 ~~    att2           1 0.150     0.006  24.613       0    0.138
#> 27    att3 ~~    att3           1 0.160     0.006  26.274       0    0.148
#> 28    att4 ~~    att4           1 0.162     0.006  27.534       0    0.151
#> 29    att5 ~~    att5           1 0.159     0.006  24.829       0    0.146
#> 30     sn1 ~~     sn1           1 0.178     0.015  12.026       0    0.149
#> 31     sn2 ~~     sn2           1 0.157     0.012  13.180       0    0.133
#> 32    int1 ~~    int1           1 0.157     0.009  18.042       0    0.140
#> 33    int2 ~~    int2           1 0.160     0.008  20.330       0    0.145
#> 34    int3 ~~    int3           1 0.168     0.007  23.461       0    0.154
#> 35      b1 ~~      b1           1 0.186     0.019  10.017       0    0.150
#> 36      b2 ~~      b2           1 0.135     0.017   8.041       0    0.102
#> 37     ATT ~~     ATT           1 0.998     0.037  27.109       0    0.926
#> 38     ATT ~~      SN           1 0.629     0.029  21.934       0    0.573
#> 39      SN ~~      SN           1 0.988     0.039  25.371       0    0.911
#> 40     PBC ~~     ATT           1 0.678     0.029  23.709       0    0.622
#> 41     PBC ~~      SN           1 0.678     0.029  23.328       0    0.621
#> 42     PBC ~~     PBC           1 0.963     0.035  27.237       0    0.893
#> 43     PBC ~~ INT:PBC           1 0.000        NA      NA      NA       NA
#> 44     INT ~~     INT           1 0.491     0.020  24.595       0    0.452
#> 45     INT ~~ INT:PBC           1 0.000        NA      NA      NA       NA
#> 46     BEH ~~     BEH           1 0.455     0.023  20.027       0    0.411
#> 47 INT:PBC ~~ INT:PBC           1 0.971        NA      NA      NA       NA
#>    ci.upper
#> 1        NA
#> 2     0.902
#> 3     0.812
#> 4     0.717
#> 5     0.911
#> 6        NA
#> 7     0.921
#> 8        NA
#> 9     0.938
#> 10    0.824
#> 11       NA
#> 12    0.944
#> 13    0.836
#> 14       NA
#> 15    1.020
#> 16    0.265
#> 17    0.231
#> 18    0.275
#> 19    0.276
#> 20    0.238
#> 21    0.240
#> 22    0.160
#> 23    0.175
#> 24    0.168
#> 25    0.181
#> 26    0.162
#> 27    0.171
#> 28    0.174
#> 29    0.171
#> 30    0.207
#> 31    0.180
#> 32    0.174
#> 33    0.176
#> 34    0.182
#> 35    0.222
#> 36    0.168
#> 37    1.070
#> 38    0.686
#> 39    1.064
#> 40    0.734
#> 41    0.735
#> 42    1.032
#> 43       NA
#> 44    0.530
#> 45       NA
#> 46    0.500
#> 47       NA