library(lavaan) mat<-' 1 0.38 1 0.26 0.23 1 -0.06 0.13 0.05 1 0.1 0.18 -0.03 0.31 1 0.13 0.23 0.01 0.15 0.38 1 0.06 0.07 0.06 0.05 0.2 0.38 1 0.16 0.24 0.05 0.2 0.34 0.5 0.2 1 0.21 0.16 0.09 0.15 0.38 0.24 0.32 0.5 1 0.14 0.12 0.08 0.19 0.35 0.25 0.15 0.41 0.32 1 -0.13 -0.14 -0.03 -0.16 -0.3 -0.24 -0.18 -0.27 -0.27 -0.38 1 ' wheaton.cov <- getCov(mat,names=c("x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11")) sd<-c(0.5, 0.8, 0.6, 0.8, 0.9, 1.3, 1.3, 4.3, 5.2, 9.6, 1.0) full.cov <- lavaan:::cor2cov(wheaton.cov,sd,names=c("x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11")) model<-' F1=~x1+x2+x3 F2=~x4+x5 F3=~x6+x7 F4=~x8+x9 F5=~x10 F6=~x11 F1~~F2 F3~F1 F4~F2+F3 F5~F4 F6~F4+F5 x10~~10.14*x10 x11~~0.35*x11 x5~~x6 ' fit <- lavaan:::sem(model, sample.cov=full.cov, sample.nobs=338) summary(fit, standardized=TRUE) latent<-c("F1","F2","F3","F4","F5","F6") makeawk(latent) pars <- parameterEstimates(fit, standardized = TRUE) g<-data.frame(pars$lhs,pars$op,pars$rhs," [label=",signif(pars$std.all,digits=3),"];") write.table(g,"out",sep=" ",col.names=FALSE,row.names=FALSE,quote=FALSE, na="") system( 'gawk -f "lavaan_dot.awk" "out">out.dot')
|