# --------------------------------------------------------------------- # Program: MultiRegRaw-OpenMx100214.R # Author: Steven M. Boker # Date: Sun Feb 14 13:34:33 EST 2010 # # This program fits a FIML multiple regression model to the # multiData simulated data. # # # --------------------------------------------------------------------- # Revision History # -- Sun Feb 14 13:34:36 EST 2010 # Created MultiRegRaw-OpenMx100214.R. # # --------------------------------------------------------------------- # ---------------------------------- # Read libraries and set options. options(width=80) require(psych) require(OpenMx) # ---------------------------------- # Read the data and print descriptive statistics. multiData1 <- read.csv("multiData.csv") describe(multiData1) # ---------------------------------- # Build an OpenMx multiple regression model using y and x1 predictors <- c("x1", "x2", "x3", "x4") outcomes <- c("y") manifests <- names(multiData1) multiRegModel <- mxModel("FIML Multiple Regression of y on x1, x2, x3, & x4", type="RAM", manifestVars=manifests, mxPath(from=predictors, to=outcomes, arrows=1, free=TRUE, values=.2, labels=c("b1", "b2", "b3", "b4")), mxPath(from=outcomes, arrows=2, free=TRUE, values=.8, labels=c("VarE")), mxPath(from=predictors, to=predictors, arrows=2, all=TRUE, free=TRUE, values=.2), mxPath(from=manifests, arrows=2, free=TRUE, values=.8, labels=c("VarX1", "VarX2", "VarX3", "VarX4", "VarE")), mxPath(from="one", to=manifests, arrows=1, free=TRUE, values=.1, labels=c("MeanX1", "MeanX2", "MeanX3", "MeanX4", "MeanY")), mxData(observed=multiData1, type="raw") ) multiRegModelOut <- mxRun(multiRegModel) summary(multiRegModelOut)