OpenMx package for Structural Equation Model in R
OpenMx (Boker et al, 2011) is claimed to be a “ free and open source software for use with R that allows estimation of a wide variety of advanced multivariate statistical models.” contributed by experts in R and SEM.
The following is my OpenMx script I used in my presentation at R useR! 2011.
##-------------------------------------------------## ## Measuring Transaction Cost in Supply Chains ## ## Pairach Piboonrungroj ## ## R useR conference August 2011 ## ##-------------------------------------------------## #install OpenMx source('http://openmx.psyc.virginia.edu/getOpenMx.R') require(OpenMx) # load the OpenMx package into R library(OpenMx) # read the data into an R dataframe hoteldata <- read.csv("http://dl.dropbox.com/u/46344142/useR2011/cleandata.csv") # define which indicators load on each factor indicatorsTC <- c("TC1", "TC2", "TC3", "TC6", "TC7" , "TC11" , "TC13") indicatorsAS <- c("AS1", "AS2") indicatorsUN <- c("UN1", "UN2") # create a vector of all of the manifest variables manifests <- c(indicatorsTC, indicatorsAS, indicatorsUN) # define which indicator is to be used to scale each factor scaleTC <- c("TC1") scaleAS <- c("AS1") scaleUN <- c("UN1") # define the names of the factors latents <- c("TC", "AS", "UN") # define the MxModel and store it into "factorModel" factorModel <- mxModel("TC Model", type="RAM", manifestVars = manifests, latentVars = latents, # specify the free factor loadings mxPath(from="TC", to=indicatorsTC, free=TRUE, values=.2), mxPath(from="AS", to=indicatorsAS, free=TRUE, values=.2), mxPath(from="UN", to=indicatorsUN, free=TRUE, values=.2), # scale the two latent variables mxPath(from="TC", to=scaleTC, free=FALSE, values=1), mxPath(from="AS", to=scaleAS, free=FALSE, values=1), mxPath(from="UN", to=scaleUN, 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 path mxPath(from="AS", to="TC", arrows=2, free=TRUE, values=.3), mxPath(from="UN", to="TC", arrows=2, free=TRUE, values=.3), mxPath(from="AS", to="UN", 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(hoteldata, type="raw") ) # run the factor model factorModelOut <- mxRun(factorModel) # print a summary of the results summary(factorModelOut) <pre>
See more details about the model and the comparison with other R packages and software
6 Comments
Post a comment
I do not leave a response, but after browsing a bunch of comments here OpenMx package for Structural Equation Model in R | Pairach Piboonrungroj.
I do have a few questions for you if you tend not to
mind. Could it be just me or do a few of these comments appear like they are written by brain
dead folks? 😛 And, if you are writing at
additional online sites, I would like to keep up with
anything new you have to post. Could you list of every one
of all your shared pages like your Facebook page, twitter feed, or linkedin profile?
Hi there! Someone in my Facebook group shared this website with us so I came to give it a look.
I’m definitely enjoying the information. I’m book-marking and
will be tweeting this to my followers! Terrific blog and fantastic style and design.
Я считаю, что Вы не правы. Предлагаю это обсудить.
Пишите мне в PM.