# \donttest{
data(Cheung09)
#### Fixed-effects model: Stage 1 analysis
fixed1 <- tssem1(Cheung09$data, Cheung09$n, method="FEM")
summary(fixed1)
## Three-factor CFA model in lavaan syntax
model <- "## Factor loadings
f1 =~ f1x1*x1 + f1x2*x2 + f1x3*x3
f2 =~ f2x4*x4 + f2x5*x5 + f2x6*x6 + f2x7*x7
f3 =~ f3x8*x8 + f3x9*x9
## Factor correlations
f1 ~~ corf2f1*f2
f1 ~~ corf3f1*f3
f2 ~~ corf3f2*f3"
RAM1 <- lavaan2RAM(model, obs.variables=paste0("x", 1:9))
RAM1
## ## Equivalent RAM specification using create.mxMatrix()
## Phi <- create.mxMatrix( c("0.3*corf2f1","0.3*corf3f1","0.3*corf3f2"),
## type="Stand", as.mxMatrix=FALSE )
## Psi <- create.mxMatrix( paste("0.2*e", 1:9, sep=""), type="Diag",
## as.mxMatrix=FALSE )
## S1 <- bdiagMat(list(Psi, Phi))
## S1 <- as.mxMatrix(S1)
##
## Lambda <- create.mxMatrix( c(".3*f1x1",".3*f1x2",".3*f1x3",rep(0,9),
## ".3*f2x4",".3*f2x5",".3*f2x6",".3*f2x7",
## rep(0,9),".3*f3x8",".3*f3x9"), type="Full",
## ncol=3, nrow=9, as.mxMatrix=FALSE )
## Zero1 <- matrix(0, nrow=9, ncol=9)
## Zero2 <- matrix(0, nrow=3, ncol=12)
## A1 <- rbind( cbind(Zero1, Lambda), Zero2 )
## A1 <- as.mxMatrix(A1)
##
## F1 <- create.Fmatrix(c(rep(1,9), rep(0,3)))
#### Fixed-effects model: Stage 2 analysis
fixed2 <- tssem2(fixed1, RAM=RAM1, intervals.type="LB")
summary(fixed2)
## Display the model
plot(fixed2, what="path")
## Display the model with the parameter estimates
plot(fixed2, latNames=c("f1", "f2", "f3"), edge.label.cex=0.8,
color="yellow")
# }
Run the code above in your browser using DataLab