I am trying to recreate this model result.
It has 6 exogenous covariates, one latent variable, two covariances, and four variances (at least that's how I interpret it). I extracted the correlation matrix from the paper. Here is the R syntax I am using.
x.cor <- " 0.47
0.15 0.09
-0.02 0.26 0.31
0.14 0.16 0.08 0.13
-0.15 -0.04 0.11 0.04 0.61
0.15 0.09 -0.16 -0.33 0.02 -0.07
0.05 0.12 0.22 0.15 0.55 0.36 -0.25
-0.19 0.03 -0.03 -0.03 -0.06 -0.03 0.27 -0.02
0.04 0.07 0.12 -0.04 -0.13 -0.10 0.10 -0.17 -0.01"
sds <- c(0.63,0.53,0.59,0.51,0.48,0.61,4.31,3.60,2.17,0.51)
N <- 55
nms <- c('dadRateMomProblemSolving','dadRateYouthProblemSolving','momRateDadProblemSolving','momRateYouthProblemSolving','youthRateMomProblemSolving','youthRateDadProblemSolving','youthDelinquency','youthSelfesteem','youthAge','youthSex')
x.cov <- getCov(x.cor, sds=sds, lower=T, diagonal=F,names=nms)
mod1 <- '
# Latent variable
famProbSolve =~ momRateYouthProblemSolving + dadRateYouthProblemSolving + momRateDadProblemSolving + dadRateMomProblemSolving + youthRateMomProblemSolving + youthRateDadProblemSolving
# Covariances
momRateYouthProblemSolving ~~ dadRateYouthProblemSolving
youthRateMomProblemSolving ~~ youthRateDadProblemSolving
# Variances
momRateYouthProblemSolving ~~ momRateYouthProblemSolving
dadRateYouthProblemSolving ~~ dadRateYouthProblemSolving
youthRateMomProblemSolving ~~ youthRateMomProblemSolving
youthRateDadProblemSolving ~~ youthRateDadProblemSolving'
m1.fit <- lavaan(mod1, model.type='cfa', sample.cov = x.cov, sample.nobs = N, estimator='ML',
fixed.x = F, auto.var=F)
parameterEstimates(m1.fit, ci=T, boot.ci.type='norm')
fitMeasures(m1.fit)And when I run I get:
> m1.fit <- lavaan(mod1, model.type='cfa', sample.cov = x.cov, sample.nobs = N, estimator='ML', + fixed.x = F, auto.var=F) Error in estimateModel(lavaanModel, samplestats = lavaanSampleStats, X = lavaanData@X, : lavaan ERROR: initial model-implied matrix (Sigma) is not positive definite; check your model and/or starting parameters.
Any thoughts? Thanks for any help you can give!
--
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 http://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.
x.cor <- " 0.47
0.15 0.09
-0.02 0.26 0.31
0.14 0.16 0.08 0.13
-0.15 -0.04 0.11 0.04 0.61
0.15 0.09 -0.16 -0.33 0.02 -0.07
0.05 0.12 0.22 0.15 0.55 0.36 -0.25
-0.19 0.03 -0.03 -0.03 -0.06 -0.03 0.27 -0.02
0.04 0.07 0.12 -0.04 -0.13 -0.10 0.10 -0.17 -0.01"
sds <- c(0.63,0.53,0.59,0.51,0.48,0.61,4.31,3.60,2.17,0.51)
means <- c(3.92,3.84,3.62,3.86,3.78,3.72,18.01,26.38,14.02,0.50)
N <- 55
nms <- c('dm','dy','md','my','ym','yd','youthDelinquency','youthSelfesteem','youthAge','youthSex')
x.cov <- getCov(x.cor, sds=sds, lower=T, diagonal=F,names=nms)
mod1 <- '
# Latent variable
famProbSolve =~ my + dy + md + dm + ym + yd
# Fix variance of famProbSolve
famProbSolve ~~ 1 * famProbSolve
dm ~~ e1 * dm
dy ~~ e2 * dy
md ~~ e3 * md
my ~~ e4 * my
ym ~~ e5 * ym
yd ~~ e6 * yd
'
rm('m1.fit')
fitMeasures(m1.fit <- lavaan(mod1, model.type='cfa', sample.cov = x.cov, sample.nobs = N, control=list(x.tol=1e-6),
estimator='ML', fixed.x = F, auto.var=T))[c('chisq','df','pvalue','cfi')]
parameterEstimates(m1.fit, ci=T, boot.ci.type='norm')
fitMeasures(m1.fit)