# NOT RUN {
# Load Libraries
require(umx);
# =========================
# = Load and Process Data =
# =========================
data('us_skinfold_data')
# rescale variables
us_skinfold_data[,c('bic_T1', 'bic_T2')] <- us_skinfold_data[,c('bic_T1', 'bic_T2')]/3.4
us_skinfold_data[,c('tri_T1', 'tri_T2')] <- us_skinfold_data[,c('tri_T1', 'tri_T2')]/3
us_skinfold_data[,c('caf_T1', 'caf_T2')] <- us_skinfold_data[,c('caf_T1', 'caf_T2')]/3
us_skinfold_data[,c('ssc_T1', 'ssc_T2')] <- us_skinfold_data[,c('ssc_T1', 'ssc_T2')]/5
us_skinfold_data[,c('sil_T1', 'sil_T2')] <- us_skinfold_data[,c('sil_T1', 'sil_T2')]/5
# Select Variables for Analysis
varList = c('ssc','sil','caf','tri','bic')
selVars = umx_paste_names(varList, "_T", 1:2)
# Data objects for Multiple Groups
mzmData = subset(us_skinfold_data, zyg == 1, selVars)
dzmData = subset(us_skinfold_data, zyg == 3, selVars)
mzfData = subset(us_skinfold_data, zyg == 2, selVars)
dzfData = subset(us_skinfold_data, zyg == 4, selVars)
dzoData = subset(us_skinfold_data, zyg == 5, selVars)
m1 = umxACESexLim(selDVs = varList, suffix = "_T",
mzmData = mzmData, dzmData = dzmData,
mzfData = mzfData, dzfData = dzfData,
dzoData = dzoData)
m1 = mxRun(m1)
# ===================================================
# = Test switching specific a from Males to females =
# ===================================================
m2 = umxSetParameters(m1, labels = "asm_.*", free = FALSE, values = 0, regex = TRUE)
m2 = umxSetParameters(m1, labels = "asf_.*", free = TRUE , values = 0, regex = TRUE)
m2 = mxRun(m2)
summary(m2)
umxCompare(m2, m1)
# does fit move on repeated execution?
# for (i in 1:4) { m2 <- mxRun(m2); print(m2 $output$mi) }
# }
Run the code above in your browser using DataLab