
umxGxE_window(selDVs = NULL, moderator = NULL, mzData = mzData, dzData = dzData, suffix = NA, weightCov = FALSE, target = NULL, width = 1, plotWindow = FALSE, return = c("estimates", "last_model"))
Briley, D.A., Harden, K.P., Bates, T.C., Tucker-Drob, E.M. (2015). Nonparametric Estimates of Gene x Environment Interaction Using Local Structural Equation Modeling. Behavior Genetics.
plot.MxModel
,
umxACESexLim
, umxACEcov
,
umxACE
, umxCF_SexLim
,
umxCP
, umxGxE
,
umxIP
, umxPlotACEcov
,
umxPlotCP
, umxPlotGxE
,
umxPlotIP
, umxSummaryACEcov
,
umxSummaryACE
, umxSummaryCP
,
umxSummaryGxE
, umxSummaryIP
,
umx_make_TwinData
, umx
library(umx);
# ==============================
# = 1. Open and clean the data =
# ==============================
# umxGxE_window takes a dataframe consisting of a moderator and two DV columns: one for each twin
mod = "age" # The 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. First we label them
# TODO: Q for OpenMx team: can I add a cohort column to this dataset?
twinData$cohort = 1; twinData$cohort[twinData$zyg %in% 6:10] = 2
twinData$zyg[twinData$cohort == 2] = twinData$zyg[twinData$cohort == 2]-5
# And set a plain-English label
labList = c("MZFF", "MZMM", "DZFF", "DZMM", "DZOS")
twinData$ZYG = factor(twinData$zyg, levels = 1:5, labels = labList)
# The model also assumes two groups: MZ and DZ. Moderator can't be missing
# Delete missing moderator rows
twinData = twinData[!is.na(twinData[mod]),]
mzData = subset(twinData, ZYG == "MZFF", c(selDVs, mod))
dzData = subset(twinData, ZYG == "DZFF", c(selDVs, mod))
# ========================
# = 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)
## Not run:
# # Run with FIML (default) uses all information
# umxGxE_window(selDVs = selDVs, moderator = mod, mzData = mzData, dzData = dzData);
#
# # Run creating weighted covariance matrices (excludes missing data)
# umxGxE_window(selDVs = selDVs, moderator = mod, mzData = mzData, dzData = dzData,
# weightCov = TRUE);
# ## End(Not run)
Run the code above in your browser using DataLab