if (FALSE) {
library(umx);
# ==============================
# = 1. Open and clean the data =
# ==============================
# umxGxE_window takes a data.frame consisting of a moderator and two DV columns: one for each twin.
# The model assumes two groups (MZ and DZ). Moderator can't be missing
mod = "age" # The full name of the moderator column in the dataset
selDVs = c("bmi1", "bmi2") # The DV for twin 1 and twin 2
data(twinData) # Dataset of Australian twins, built into OpenMx
# The twinData consist of two cohorts: "younger" and "older".
# zygosity is a factor. levels = MZFF, MZMM, DZFF, DZMM, DZOS.
# Delete missing moderator rows
twinData = twinData[!is.na(twinData[mod]), ]
mzData = subset(twinData, zygosity == "MZFF")
dzData = subset(twinData, zygosity == "DZFF")
# ========================
# = 2. Run the analyses! =
# ========================
# Run and plot for specified windows (in this case just 1927)
umxGxE_window(selDVs = selDVs, moderator = mod, mzData = mzData, dzData = dzData,
target = 40, plotWindow = TRUE)
umxGxE_window(selDVs = "bmi", sep="", moderator = mod, mzData = mzData, dzData = dzData,
target = 40, plotWindow = TRUE, tryHard = "yes")
# Run with tryHard
umxGxE_window(selDVs = "bmi", sep="", moderator = "age", mzData = mzData, dzData = dzData)
umxGxE_window(selDVs="bmi", sep="", moderator="age", mzData=mzData, dzData=dzData, tryHard="yes")
# Run creating weighted covariance matrices (excludes missing data)
umxGxE_window(selDVs = "bmi", sep="", moderator= "age", mzData = mzData, dzData = dzData,
weightCov = TRUE)
# This example runs multiple target moderator values
mxGxE_window(selDVs = selDVs, moderator = mod, mzData = mzData, dzData = dzData,
target = c(39,40,50), plotWindow = TRUE)
}
Run the code above in your browser using DataLab