# NOT RUN {
require(umx)
data(twinData)
# Replicate age to age1 & age2
twinData$age1 = twinData$age2 = twinData$age
# 80 rows so example runs fast for CRAN
mzData = subset(twinData, zygosity == "MZFF")[1:80, ]
dzData = subset(twinData, zygosity == "DZFF")[1:80, ]
# }
# NOT RUN {
mzData = subset(twinData, zygosity == "MZFF")
dzData = subset(twinData, zygosity == "DZFF")
# }
# NOT RUN {
# =====================================================================
# = Trying to use identical var (like age) as a random cov is ILLEGAL =
# =====================================================================
# }
# NOT RUN {
m1 = umxACEcov(selDVs = "bmi", selCovs = "age", dzData = dzData, mzData = mzData, sep = "")
# }
# NOT RUN {
# ========================================================
# = Use an lm-based age-residualisation approach instead =
# ========================================================
resid_data = umx_residualize("bmi", "age", suffixes=1:2, twinData)
mzData = subset(resid_data, zygosity == "MZFF")
dzData = subset(resid_data, zygosity == "DZFF")
m2 = umxACE("resid", selDVs = "bmi", dzData = dzData, mzData = mzData, suffix = "")
# Univariate BMI without covariate of age for comparison
mzData = subset(twinData, zygosity == "MZFF")
dzData = subset(twinData, zygosity == "DZFF")
m3 = umxACE("raw_bmi", selDVs = "bmi", dzData = dzData, mzData = mzData, suffix = "")
# }
# NOT RUN {
# ===========================================================================
# = A bivariate example (need a dataset with a VIABLE COVARIATE to do this) =
# ===========================================================================
selDVs = c("ht", "wt") # Set the DV
selCovs = c("income") # Set the COV
selVars = umx_paste_names(selDVs, covNames = selCovs, sep = "", suffixes = 1:2)
# 80 rows so example runs fast on CRAN
mzData = subset(twinData, zygosity == "MZFF", selVars)[1:80, ]
dzData = subset(twinData, zygosity == "DZFF", selVars)[1:80, ]
m1 = umxACEcov(selDVs = selDVs, selCovs = selCovs,
dzData = dzData, mzData = mzData, suffix = "", autoRun = TRUE
)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab