Re: Problem with MTMM simulation with higher order trait

51 views
Skip to first unread message
Message has been deleted

Alex Schoemann

unread,
Oct 29, 2018, 9:02:03 AM10/29/18
to lavaan
Hi Hacer,

It seems like your specification of the higher order trait is the issue. One thing to consider, you haven't explicitly specified the variances/residual variances of the latent variables. I'm guessing they're being set to 1, and this is likely the culprit for your error. I'd recommend explicitly setting those values to help with debugging (further, I'd guess that including residual covariances between all lower order latent variables isn't helping here).

Alex

On Sunday, October 28, 2018 at 3:10:08 PM UTC-4, Hacer Karamese wrote:
Hello everyone, 

I'm trying to simulate mtmm data with higher order trait. When I use the code below I get this error message : " Error in MASS::mvrnorm(n = sample.nobs[g], mu = Mu.hat[[g]], Sigma = COV,  : 'Sigma' is not positive definite "

When I remove the second order trait, the code works without problem. What is the problem with my code?

Thanks,
Hacer

Model1<-'
##traits
ListeningSpeaking=~ .49*CELDTls + .95*ELDlo+.95*ELDlt
Reading=~ .55*CELDTr+ .98*ELDwa+.97*ELDfv+.95*ELDc+.94*ELDlr
Writing=~ .60*CELDTw+ .96*ELDw+.95*ELDwc

##methods
CELDT=~.35*CELDTls +.65*CELDTr +.69*CELDTw 
ELD=~.28*ELDlo +.27*ELDlt +.16*ELDwa +.21*ELDfv +.30*ELDc +.31*ELDlr +.23*ELDw +.24*ELDwc

##higher order trait
HOT=~ .957*ListeningSpeaking+.999*Reading+.991*Writing

##trait correlations
ListeningSpeaking~~.5*Reading
ListeningSpeaking~~.5*Writing
Writing~~.5*Reading

# methods correlation
CELDT ~~.3*ELD

##zero cross covariances
ListeningSpeaking~~0*CELDT
Reading~~0*CELDT
Writing ~~0*CELDT

ListeningSpeaking~~0*ELD
Reading~~0*ELD
Writing ~~0*ELD

HOT~~0*CELDT
HOT~~0*ELD

##distribution of categories in each indicator 
CELDTls|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
CELDTr|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
CELDTw|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDlo|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDlt|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDwa|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDfv|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDc|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDlr|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDw|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
ELDwc|-.70*t1+ .39*t2+ 1.16*t3+ 2.05*t4
'


Model<-'ListeningSpeaking=~ ELDlt+CELDTls + ELDlo
Reading=~ ELDwa+CELDTr+ ELDfv+ELDc+ELDlr
Writing=~ ELDw+CELDTw+ELDwc

CELDT=~CELDTls +CELDTr +CELDTw 
ELD=~ELDlo +ELDlt +ELDwa +ELDfv +ELDc +ELDlr +ELDw +ELDwc 

HOT=~ ListeningSpeaking+Reading+Writing

ListeningSpeaking~~0*CELDT
Reading~~0*CELDT
Writing ~~0*CELDT

ListeningSpeaking~~0*ELD
Reading~~0*ELD
Writing ~~0*ELD 

HOT~~0*CELDT
HOT~~0*ELD

'
Output1 <- sim(10,model=Model, n=500, generate=Model1, dataOnly= TRUE) #raw data only

Output2 <- sim(100,model=Model, n=1000, generate=Model1, std.lv=TRUE, model.type= "cfa", estimator= 'WLSMV')

mysample<-simulateData(Model1, model.type = "cfa", seed=1234, sample.nobs = 5000, return.type = "data.frame")

complete.fit<-cfa(Model, data=mysample,
                  ordered= c('CELDTls', 'CELDTr', 'CELDTw','ELDlo', 'ELDlt', 'ELDwa', 'ELDfv' ,'ELDc' ,'ELDlr', 'ELDw', 'ELDwc'),      
                  estimator= 'DWLS', mimic= 'Mplus', std.lv=T, std.ov=T)

Hacer Karamese

unread,
Oct 29, 2018, 10:17:25 AM10/29/18
to lav...@googlegroups.com
Hi Alex,

Thanks for your feedback. Unfortunately, fixing variances of higher and/or lower latent variables doesn't solve the problem.

Thanks,
Hacer 

--
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 post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Terrence Jorgensen

unread,
Nov 2, 2018, 7:58:08 AM11/2/18
to lavaan
" Error in MASS::mvrnorm(n = sample.nobs[g], mu = Mu.hat[[g]], Sigma = COV,  : 'Sigma' is not positive definite "

This means your population covariance matrix is not possible.  To see why, run this code to see what your model implies Sigma would be:

fitted(sem(Model1))

As you can see, the diagonal elements are 1, so this is a correlation matrix.  But there are several correlations > 1, which makes Sigma NPD.

Try setting the population factor variances to values < 1, and check the implied Sigma by trial and error until you find values that work.  From a practical standpoint, starting with loadings nearly == 1 does not leave you a lot of wiggle room if you are considering those to be standardized loadings, because nearly all their variance is due to that common factor (so that doesn't leave a method factor much variance to explain).

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Reply all
Reply to author
Forward
Message has been deleted
0 new messages