paperKB
coga / coga-kb
Help
Sign in

Chunk #31 — Example Scripts — Path Analysis Method

Source
OpenMx: An Open Source Extended Structural Equation Modeling Framework.
Embedded
yes

Text

on each factor indicatorsF1 <- c(“x1”, “x2”, “x3”, “x4”, “x5”) indicatorsF2 <- c(“y1”, “y2”, “y3”, “y4”, “y5”) # create a vector of all of the manifest variables manifests <- c(indicatorsF1, indicatorsF2) # define which indicator is to be used to scale each factor scaleF1 <- c(“x1”) scaleF2 <- c(“y1”) # define the names of the factors latents <- c(“F1”, “F2”) # define the MxModel and store it into “factorModel“ factorModel <- mxModel(“Simple Structure Two Factor”, type=“RAM”, manifestVars = manifests, latentVars = latents, # specify the free factor loadings mxPath(from=“F1”, to=indicatorsF1, free=TRUE, values=.2), mxPath(from=“F2”, to=indicatorsF2, free=TRUE, values=.2), # scale the two latent variables mxPath(from=“F1”, to=scaleF1, free=FALSE, values=1), mxPath(from=“F2”, to=scaleF2, free=FALSE, values=1), # specify the unique variances mxPath(from=manifests, arrows=2, free=TRUE, values=.8), # specify the factor variances mxPath(from=latents, arrows=2, free=TRUE, values=.8), # specify the factor covariance mxPath(from=“F1”, to=“F2”, arrows=2, free=TRUE, values=.3), # specify the mean structure mxPath(from=“one”, to=c(manifests, latents), arrows=1, free=FALSE, values=0), # attach the data to the model mxData(factorData, type=“raw”) ) # run the factor model factorModelOut <- mxRun(factorModel) # print a summary of the results summary(factorModelOut)