# NOT RUN {
data(twinData)
selDVs = c("wt", "ht")
mzData = twinData[twinData$zygosity %in% "MZFF", ]
dzData = twinData[twinData$zygosity %in% "DZFF", ]
round(sqrt(var(dzData[,tvars(selDVs, "")], na.rm=TRUE)/3),3)
xmu_starts(mzData, dzData, selVars=selDVs, nSib= 2, sep="", equateMeans=TRUE, varForm="Cholesky")
# Variance instead of SD
round(var(dzData[,tvars(selDVs, "")], na.rm=TRUE)/3,3)
xmu_starts(mzData, dzData, selVars = selDVs, nSib = 2, sep= "",
equateMeans= TRUE, varForm= "Cholesky", SD= FALSE)
# one variable
xmu_starts(mzData, dzData, selVars= "wt", nSib = 2, sep="", equateMeans = TRUE)
# Ordinal/continuous mix
data(twinData)
twinData= umx_scale_wide_twin_data(data=twinData,varsToScale="wt",sep= "")
# Cut BMI column to form ordinal obesity variables
cuts = quantile(twinData[, "bmi1"], probs = c(.5, .8), na.rm = TRUE)
obLevels = c('normal', 'overweight', 'obese')
twinData$obese1= cut(twinData$bmi1,breaks=c(-Inf,cuts,Inf),labels=obLevels)
twinData$obese2= cut(twinData$bmi2,breaks=c(-Inf,cuts,Inf),labels=obLevels)
# Make the ordinal variables into mxFactors
ordDVs = c("obese1", "obese2")
twinData[, ordDVs] = umxFactor(twinData[, ordDVs])
mzData = twinData[twinData$zygosity %in% "MZFF",]
dzData = twinData[twinData$zygosity %in% "DZFF",]
xmu_starts(mzData, dzData, selVars = c("wt","obese"), sep= "",
nSib= 2, equateMeans = TRUE, SD= FALSE)
xmu_starts(mxData(mzData, type="raw"), mxData(mzData, type="raw"),
selVars = c("wt","obese"), sep= "", nSib= 2, equateMeans = TRUE, SD= FALSE)
# ==============
# = Three sibs =
# ==============
data(twinData)
twinData$wt3 = twinData$wt2
twinData$ht3 = twinData$ht2
selDVs = c("wt", "ht")
mzData = twinData[twinData$zygosity %in% "MZFF", ]
dzData = twinData[twinData$zygosity %in% "DZFF", ]
xmu_starts(mzData, dzData, selVars=selDVs, sep="", nSib=3, equateMeans=TRUE)
xmu_starts(mzData, dzData, selVars=selDVs, sep="", nSib=3, equateMeans=FALSE)
# }
Run the code above in your browser using DataLab