I am fitting the example of Bollen on political democracy with the following program:
library(lavaan)
library(semPlot)
bollen.cov = matrix(c(
6.89, 6.25, 5.84, 6.09, 5.06, 5.75, 5.81, 5.67, 0.73, 1.27, 0.91,
6.25,15.58, 5.84, 9.51, 5.6 , 9.39, 7.54, 7.76, 0.62, 1.49, 1.17,
5.84, 5.84,10.76, 6.69, 4.94, 4.73, 7.01, 5.64, 0.79, 1.55, 1.04,
6.09, 9.51, 6.69,11.22, 5.7 , 7.44, 7.49, 8.01, 1.15, 2.24, 1.84,
5.06, 5.6, 4.94, 5.7 , 6.83, 4.98, 5.82, 5.34, 1.08, 2.06, 1.58,
5.75, 9.39, 4.73, 7.44, 4.98,11.38, 6.75, 8.25, 0.85, 1.81, 1.57,
5.81, 7.54, 7.01, 7.49, 5.82, 6.75,10.8 , 7.59, 0.94, 2 , 1.63,
5.67, 7.76, 5.64, 8.01, 5.34, 8.25, 7.59,10.53, 1.1 , 2.23, 1.69,
0.73, 0.62, 0.79, 1.15, 1.08, 0.85, 0.94, 1.1, 0.54, 0.99, 0.82,
1.27, 1.49, 1.55, 2.24, 2.06, 1.81, 2 , 2.23, 0.99, 2.28, 1.81,
0.91, 1.17, 1.04, 1.84, 1.58, 1.57, 1.63, 1.69, 0.82, 1.81, 1.98),
nrow =11,ncol=11)
rownames(bollen.cov) = c("y1","y2","y3","y4","y5","y6","y7", "y8","x1","x2","x3")
colnames(bollen.cov) = c("y1","y2","y3","y4","y5","y6","y7", "y8","x1","x2","x3")
model <- '
# latent variables
ind60 =~ x1 + x2 + x3
dem60 =~ v1 *y1 + v2* y2 + v3 *y3 + v4 *y4
dem65 =~ v1 *y5 + v2* y6 + v3 *y7 + v4 *y8
# regressions
dem60 ~ ind60
dem65 ~ ind60 + dem60
# residual covariances
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
fit <- sem(model,sample.nobs = 75,sample.cov=bollen.cov)
Sometimes this works fine but sometimes I get
>
> fit <- sem(model,sample.nobs = 75,sample.cov=bollen.cov)
Error in sem.semmod(model, sample.nobs = 75, sample.cov = bollen.cov) :
S and data cannot both be missing
although the covariance matrix is given???
And when I put this program into sweave code to create a dynamic report I also get this error?
I had also a problem when I was using the sem package together with sweave: I had to put the model specification in a file and read it with specifyModel, but there is nothing similar in lavaan , is there?
Thanks for any help!
Martina
It is the namespace issue, isn't? Sharing the same name in building a function is the issue beyond a developer's manner with contributed packages. Besides, the function names, like sem or cfa does not belong to anyone in the SEM communities. I support lavaan::sem as well as sem::sem. The users should know their internal differences.
Jong-Hwa
--
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/groups/opt_out.