Latent interaction using indProd from semTools with match = TRUE

152 views
Skip to first unread message

Brian O'Neill

unread,
Jul 10, 2023, 7:21:46 PM7/10/23
to lavaan
Hi. When I run this model... 

DMC <- indProd(MYDATA,
                  var1 = c("C.1", "C.2", "C.3", "C.4"),
                  var2 = c("NE.EV.3R", "NE.A.3R", "NE.D.2", "NE.D.4R"),  
                  match = TRUE, meanC = FALSE, residualC = FALSE, doubleMC = TRUE,
                  namesProd = c("k1", "k2", "k3", "k4")) 

# Structural Model
MYFMODEL <- '
## Factor loadings
f.C =~ C.1 + C.2 + C.3 + C.4
f.N =~ NE.EV.2 + NE.EV.3R + NE.D.2 + NE.D.4R + NE.A.2 + NE.A.3R
f.OC =~ OC.2 + OC.3 + OC.4

# Interaction term
f.C_f.N =~ k1 + k2 + k3 + k4

## Estimate covariances between interaction and predictors https://osf.io/y39z6
f.C ~~ f.C_f.N
f.N ~~ f.C_f.N

## When match = "FALSE": Residual covariances: constrained to equality between the same item (Schoemann & Jorgensen, 2021)
# When match = "TRUE": residual covariances are unnecessary when using the matched-pairs strategy because
# each indicator is only used to calculate one product indicator. (Schoemann & Jorgensen, 2021)

## ? Covariances: allow because the interaction term components (k1...k4) are comprised of the indicators?
# Allow covariance
# k1 ~~ C.1 + NE.EV.3R
# k2 ~~ C.2 + NE.A.3R
# k3 ~~ C.3 + NE.D.2
# k4 ~~ C.4 + NE.D.4R


## Regression model with 3 predictors
f.OC ~ co*f.C + no*f.N + b3*f.C_f.N

## Get values for Simple Slopes (ss) # (Zyphur, 2022)
f.N ~~ Nvar*f.N                       # Need the variance of the moderator to get its standard deviation
ss_minus := co - b3*(sqrt(Nvar))
ss_mean := co                         # The effect of X at the mean of the moderator
ss_plus := co + b3*(sqrt(Nvar))
f.Nsd := sqrt(Nvar)                   # compute standard deviation of the moderator
f.Nsd3 := 3*f.Nsd

f.C ~~ Cvar*f.C                       # Need the variance of X to get its standard deviation
f.Csd := sqrt(Cvar)                   # compute standard deviation of x
f.Csd3 := 3*f.Csd
'
FIT01 <- sem(MYFMODEL, data = DMC, mimic = "Mplus", estimator = "ML", missing = "ML",
             se = "bootstrap", bootstrap = 1000, parallel = "snow", ncpus = cores)


I get the:
lavaan WARNING: covariance matrix of latent variables
                is not positive definite;
                use lavInspect(fit, "cov.lv") to investigate.


I have a negative eigenvalue:
> eigen(lavInspect(FIT01, "cov.lv"))
eigen() decomposition
$values
[1] 18.6136423  1.1920669  0.3891667 -0.2867493

However, if I allow the covariances highlighted above between the interaction term components and their indicators, then I do not get a warning and all eigenvalues are positive. 

> eigen(lavInspect(FIT01, "cov.lv"))
eigen() decomposition
$values
[1] 21.5563369  1.5833258  0.3869048  0.0951951


I thought I read that this approach was recommended, but now I can't find the source and I think I may have confused it with "Estimate covariances between interaction and predictors" from  https://osf.io/y39z6 (which I've included in the code above). I'm guessing there may be some redundancy and/or faulty logic by allowing the covariances I highlighted. Is my approach invalid? (I tried match = FALSE but that failed as well.)

Edward Rigdon

unread,
Jul 11, 2023, 1:31:07 PM7/11/23
to lav...@googlegroups.com
Your indProd() call, with match=TRUE and doubleMC=TRUE, suggests that your new product indicators (k1 ... k4) should be orthogonal to the original indicators. That is the point of the double mean centering. (You can check empirically that the correlations are 0 in your data.) That would make the highlighted free residual covariances unnecessary. The additional correlated residuals would make the model more unstable, and that could be the reason for the undesired solution. Of course, you could also check the residual covariances themselves--I would expect them to be essentially 0.

The note about allowing residual covariances applies not between original indicators and product terms but between different product indicators that employ the same original variables. With matching, as you note, this sharing does not happen. 

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/98cd7cd1-797d-4703-82ac-c771d82dd0ebn%40googlegroups.com.

Brian O'Neill

unread,
Jul 11, 2023, 7:29:17 PM7/11/23
to lavaan
Hi Ed,

Thank you very much for the response. I have a hard time keeping track of which covariance the syntax is referring to. Regarding "You can check empirically that the correlations are 0 in your data," is this what you suggest?

> resid(FIT01, type = "cor") # same as cor.bollen
$type
[1] "cor.bollen"

$cov
            C.1    C.2    C.3    C.4 NE.EV.2 NE.EV.3 NE.D.2 NE.D.4 NE.A.2 NE.A.3   OC.2   OC.3   OC.4     k1     k2     k3     k4
C.1       0.000                                                                                                                  
C.2       0.034  0.000                                                                                                          
C.3       0.010  0.043  0.000                                                                                                    
C.4      -0.012 -0.065 -0.054  0.000                                                                                            
NE.EV.2  -0.152 -0.176 -0.136 -0.049   0.000                                                                                    
NE.EV.3R  0.049  0.088 -0.029  0.059   0.070   0.000                                                                            
NE.D.2   -0.069 -0.052 -0.141  0.034  -0.049   0.030  0.000                                                                      
NE.D.4R  -0.054 -0.001 -0.066  0.025  -0.003   0.192  0.078  0.000                                                              
NE.A.2    0.090  0.166  0.033  0.213  -0.171   0.035 -0.032  0.043  0.000                                                        
NE.A.3R   0.030  0.032  0.035  0.101   0.015   0.149 -0.088  0.014 -0.083  0.000                                                
OC.2      0.006  0.046 -0.063 -0.026  -0.066  -0.076 -0.044 -0.155  0.097 -0.098  0.000                                          
OC.3     -0.001  0.056 -0.035 -0.010   0.012   0.066  0.003 -0.033  0.123 -0.056 -0.002  0.000                                  
OC.4      0.019  0.037 -0.027 -0.052  -0.056   0.024 -0.018 -0.061  0.145 -0.061  0.001  0.000  0.000                            
k1       -0.181  0.041 -0.245 -0.129  -0.132   0.074  0.353  0.098  0.097 -0.016 -0.065 -0.001 -0.055  0.000                    
k2        0.131 -0.097 -0.041  0.018   0.326   0.041 -0.136 -0.063 -0.089 -0.056 -0.004  0.078  0.046 -0.051  0.000              
k3        0.051  0.095  0.224  0.076  -0.297  -0.091 -0.260 -0.123  0.347 -0.134 -0.010  0.044  0.058 -0.049  0.015  0.000      
k4       -0.035 -0.057 -0.076  0.295  -0.161   0.031 -0.131 -0.062 -0.001  0.295 -0.074 -0.013 -0.063  0.008  0.031  0.037  0.000

$mean
     C.1      C.2      C.3      C.4  NE.EV.2 NE.EV.3R   NE.D.2  NE.D.4R   NE.A.2  NE.A.3R     OC.2     OC.3     OC.4       k1       k2       k3       k4
   0.000    0.000    0.000    0.000    0.003   -0.006    0.003   -0.001    0.000    0.002    0.000    0.000    0.000    0.001   -0.006   -0.002    0.013 


I don't see covariances that are 0. Some of the mean values are also not 0. Is this normal?

Here is the updated code (that still results in the "not positive definite" message): 

DMC <- indProd(MYDATA,
                  var1 = c("C.2", "C.1", "C.3", "C.4"),
                  var2 = c("NE.D.2", "NE.EV.2", "NE.A.2", "NE.A.3R"),  

                  match = TRUE, meanC = FALSE, residualC = FALSE, doubleMC = TRUE,
                  namesProd = c("k1", "k2", "k3", "k4"))

MYFMODEL <- '
## Factor loadings
f.C =~ C.1 + C.2 + C.3 + C.4
f.N =~ NE.EV.2 + NE.EV.3R + NE.D.2 + NE.D.4R + NE.A.2 + NE.A.3R
f.OC =~ OC.2 + OC.3 + OC.4

# Interaction term
f.C_f.N =~ k1 + k2 + k3 + k4

## Estimate covariances between interaction and predictors https://osf.io/y39z6
f.C ~~ f.C_f.N
f.N ~~ f.C_f.N

## Regression model with 3 predictors
f.OC ~ co*f.C + no*f.N + b3*f.C_f.N


Thanks again!

Brian O'Neill

unread,
Jul 11, 2023, 7:48:03 PM7/11/23
to lavaan
I'm also getting these Modification Indices (among others):

> MI
         lhs op      rhs     mi    epc sepc.lv sepc.all sepc.nox
211   NE.D.2 ~~       k1 78.530  5.004   5.004    0.916    0.916
230   NE.A.2 ~~       k3 72.971  7.776   7.776    0.795    0.795
191  NE.EV.2 ~~       k2 70.896  4.914   4.914    0.764    0.764
238  NE.A.3R ~~       k4 40.035  2.804   2.804    0.612    0.612


These are really high and I'm not sure what to make of it (back to original post!).

Edward Rigdon

unread,
Jul 11, 2023, 10:21:13 PM7/11/23
to lav...@googlegroups.com
The correlations between the product indicators and the observed variables used to create them. Double mean centering should zero out those correlations in your combined dataset.

Brian O'Neill

unread,
Jul 12, 2023, 1:31:06 AM7/12/23
to lavaan
Thank you!
Reply all
Reply to author
Forward
0 new messages