paperKB
coga / coga-kb
Help
Sign in

Chunk #34 — Example Scripts — Matrix Method

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

Text

We will respecify the model in Figure 6 as a product of matrices. This model is of factor analytic form and so the expected covariance matrix of the indicators, R, can be written as (1)R=ALA′+U, where A is the matrix of factor loadings, L is the factor intercorrelation matrix, and U is the diagonal matrix of unique factor variances. This model can be written in OpenMx using the following script. # load the OpenMx package into R library(OpenMx) # read the data into an R dataframe factorData <- read.csv(“demoTwoFactor.csv”) # read the names of the indicator variables from the dataframe indicators <- names(factorData) # define the MxModel and store it into “factorModel” factorModel <- mxModel(“One Factor”, # specify the loading matrix including its starting values and which elements are free mxMatrix(“Full”, nrow=10, ncol=2, values=c(1,rep(0.2,4),rep(0,10),1,rep(0.2,4)), free=c(FALSE,rep(TRUE,4),rep(FALSE,10),FALSE,rep(TRUE,4)), name=“A”), # specify the factor intercorrelation matrix mxMatrix(“Symm”, nrow=2, ncol=2, values=.8, free=T, name=“L”), # specify the matrix of unique factor variances mxMatrix(“Diag”, nrow=10, ncol=10, values=1, free=T, name=“U”), # specify the algebra that results in the model expectations mxAlgebra(A %*% L %*% t(A) + U, dimnames