#Set the working directory getwd() setwd("???") require(OpenMx) #Read in the data data <-read.table("ozbmi2.txt", header=T, na.strings = "NA") head(data) # using subset function create new dataset without missing data OZbmi <- subset(data, age !="NA" , select=c(bmi1, age)) RegModel <- mxModel("Regression", type="RAM", mxData(observed=OZbmi, type="raw"), manifestVars=c("age", "bmi1"), mxPath( from=c("age", "bmi1"), arrows=2, free=TRUE, values = c(1, 1), labels=c("varage", "residual") ), # variance paths mxPath( from="age", to="bmi1", arrows=1, free=TRUE, values=1, labels="beta1"), # regression weights mxPath( from="one", to=c("age", "bmi1"), arrows=1, free=TRUE, values=c(21, .1), labels=c("meanage", "beta0") )# means and intercepts ) # close model regFit <- mxRun(RegModel) summary(regFit)