## Not run:
#
# ## Random-effects model: First stage analysis
# random1 <- tssem1(my.df = Roorda11$data, n = Roorda11$n, method = "REM", RE.type = "Diag")
# summary(random1)
#
# varnames <- c("pos", "neg", "enga", "achiev")
#
# ## Prepare a regression model using create.mxMatrix()
# A <- create.mxMatrix(c(0,0,0,0,
# 0,0,0,0,
# "0.1*b31","0.1*b32",0,0,
# 0,0,"0.1*b43",0),
# type = "Full", nrow = 4, ncol = 4, byrow = TRUE,
# name = "A", as.mxMatrix = FALSE)
#
# ## This step is not necessary but it is useful for inspecting the model.
# dimnames(A) <- list(varnames, varnames)
# A
#
# S <- create.mxMatrix(c(1,
# ".5*p21",1,
# 0,0,"0.6*p33",
# 0,0,0,"0.6*p44"),
# type="Symm", byrow = TRUE,
# name="S", as.mxMatrix = FALSE)
#
# ## This step is not necessary but it is useful for inspecting the model.
# dimnames(S) <- list(varnames, varnames)
# S
#
# ## Random-effects model: Second stage analysis
# random2 <- tssem2(random1, Amatrix=A, Smatrix=S, diag.constraints=TRUE,
# intervals="LB")
# summary(random2)
#
# ## Load the library
# library("semPlot")
#
# ## Convert the model to semPlotModel object
# my.plot <- meta2semPlot(random2)
#
# ## Plot the parameter estimates
# semPaths(my.plot, whatLabels="est", nCharNodes=10, color="green")
# ## End(Not run)
Run the code above in your browser using DataLab