Hello,
I've posted here before, but am still having a bit of trouble with some errors in my code.
My model is below (N=1282, number of free parameters = 141):
#install.packages("lavaan") #for SEM
library(lavaan)
mymodel <- '
#measurement model
ent =~ sdes_q1 + sdes_q4 + sdes_q6 + sdes_q8
def =~ sdes_q2 + sdes_q3 + sdes_q5 + sdes_q7
idea =~ dssis_q1r + dssis_q2r + dssis_q3r + dssis_q4r
rIP =~ sresilience_q1 + sresilience_q2 + sresilience_q5 + sresilience_q9 + sresilience_q11 + sresilience_q13 + sresilience_q19 + sresilience_q20 + sresilience_q25
rES =~ sresilience_q4 +sresilience_q8 + sresilience_q10 + sresilience_q12 + sresilience_q14 + sresilience_q18 + sresilience_q23 + sresilience_q24
rEP =~ sresilience_q3 + sresilience_q6 + sresilience_q7 + sresilience_q11 + sresilience_q13 + sresilience_q15 + sresilience_q16 + sresilience_q17 + sresilience_q21 + sresilience_q22
bur =~ inq_q1 + inq_q2 + inq_q3 + inq_q4 + inq_q5
belonging =~ inq_q6r + inq_q7r + inq_q8 + inq_q9 + inq_q10r
dep =~ cessds_q1 + cessds_q2 + cessds_q3 + cessds_q4 + cessds_q5r + cessds_q6 + cessds_q7 + cessds_q8r + cessds_q9 + cessds_q10
#structural model
def ~ dep
ent ~ def + dep
idea ~ ent + bur + bel + rEP + rES + rIP + dep'
# model identification and estimation
modelfit <- sem(mymodel, data = mydatat1, estimator = "MLM")
summary(modelfit_ideation, fit.measures = T, standardized = T, rsquare = T)
I get two errors in my output:
1. lavaan WARNING: some estimated lv variances are negative
I should note that the model above is a direct replication study of a published SEM in MPlus (but using a different sample). My current understanding is that this error may be a result of a misspecified model, but I can't say for sure.
and
2. When I try to print the R square values for my latent variables, I get NA for one of them.
These errors don't happen when I include a different outcome variable that is binary ('ordered') and specify my model estimation as DWLS.
In the output, I also seem to get two columns worth of values (e.g. fo CFI and TLI), and I can't seem to find guidance as to which one to take note of:
I'm quite new to this, and I'd really appreciate some guidance on these errors, and what I could be doing wrong.
Many thanks!