Description Usage Arguments Details Value References See Also Examples
View source: R/build_run_modify.R
Make a 2group Common Pathway twin model (Commonfactor commonpathway multivariate model).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  umxCP(
name = "CP",
selDVs,
dzData = NULL,
mzData = NULL,
sep = NULL,
nFac = 1,
type = c("Auto", "FIML", "cov", "cor", "WLS", "DWLS", "ULS"),
data = NULL,
zyg = "zygosity",
allContinuousMethod = c("cumulants", "marginals"),
correlatedA = FALSE,
dzAr = 0.5,
dzCr = 1,
autoRun = getOption("umx_auto_run"),
tryHard = c("no", "yes", "ordinal", "search"),
optimizer = NULL,
equateMeans = TRUE,
weightVar = NULL,
bVector = FALSE,
boundDiag = 0,
addStd = TRUE,
addCI = TRUE,
numObsDZ = NULL,
numObsMZ = NULL,
freeLowerA = FALSE,
freeLowerC = FALSE,
freeLowerE = FALSE
)

name 
The name of the model (defaults to "CP"). 
selDVs 
The variables to include. omit sep in selDVs, i.e., just "dep" not c("dep_T1", "dep_T2"). 
dzData 
The DZ dataframe. 
mzData 
The MZ dataframe. 
sep 
(required) The suffix for twin 1 and twin 2, often "_T". 
nFac 
How many common factors (default = 1) 
type 
One of "Auto", "FIML", "cov", "cor", "WLS", "DWLS", "ULS" 
data 
If provided, dzData and mzData are treated as valid levels of zyg to select() data sets (default = NULL) 
zyg 
If data provided, this column is used to select rows by zygosity (Default = "zygosity") 
allContinuousMethod 
"cumulants" or "marginals". Used in allcontinuous WLS data to determine if a means model needed. 
correlatedA 
?? (default = FALSE). 
dzAr 
The DZ genetic correlation (defaults to .5, vary to examine assortative mating). 
dzCr 
The DZ "C" correlation (defaults to 1: set to .25 to make an ADE model). 
autoRun 
Whether to run the model (default), or just to create it and return without running. 
tryHard 
Default ('no') uses normal mxRun. "yes" uses mxTryHard. Other options: "ordinal", "search" 
optimizer 
optionally set the optimizer (default NULL does nothing). 
equateMeans 
Whether to equate the means across twins (defaults to TRUE). 
weightVar 
If provided, a vector objective will be used to weight the data. (default = NULL). 
bVector 
Whether to compute rowwise likelihoods (defaults to FALSE). 
boundDiag 
= Numeric lbound for diagonal of the a_cp, c_cp, & e_cp matrices. Set = NULL to ignore. 
addStd 
Whether to add the algebras to compute a std model (defaults to TRUE). 
addCI 
Whether to add the interval requests for CIs (defaults to TRUE). 
numObsDZ 
= not yet implemented: Ordinal Number of DZ twins: Set this if you input covariance data. 
numObsMZ 
= not yet implemented: Ordinal Number of MZ twins: Set this if you input covariance data. 
freeLowerA 
(ignore): Whether to leave the lower triangle of A free (default = FALSE). 
freeLowerC 
(ignore): Whether to leave the lower triangle of C free (default = FALSE). 
freeLowerE 
(ignore): Whether to leave the lower triangle of E free (default = FALSE). 
The commonpathway model provides a powerful tool for theorybased decomposition of genetic and environmental differences.
umxCP supports this with pairs of monozygotic (MZ) and dizygotic (DZ) twins reared together to model the genetic and environmental structure of multiple phenotypes (measured behaviors).
Commonpathway path diagram:
As can be seen, each phenotype also by default has A, C, and E influences specific to that phenotype.
Features include the ability to include more than one common pathway, to use ordinal data.
note: The function umx_set_mvn_optimization_options
() allow users to see and set mvnRelEps
and mvnMaxPointsA
It defaults to .001. You might find that '0.01' works better for ordinal models.
Like the umxACE()
model, the CP model decomposes phenotypic variance
into Additive genetic, unique environmental (E) and, optionally, either
common or sharedenvironment (C) or
nonadditive genetic effects (D).
Unlike the Cholesky, these factors do not act directly on the phenotype. Instead latent A, C, and E influences impact on one or more latent factors which in turn account for variance in the phenotypes (see Figure).
Data Input Currently, the umxCP function accepts only raw data. This may change in future versions.
Ordinal Data
In an important capability, the model transparently handles ordinal (binary or multilevel ordered factor data) inputs, and can handle mixtures of continuous, binary, and ordinal data in any combination.
Additional features
The umxCP function supports varying the DZ genetic association (defaulting to .5) to allow exploring assortative mating effects, as well as varying the DZ “C” factor from 1 (the default for modeling familylevel effects shared 100% by twins in a pair), to .25 to model dominance effects.
Matrices and Labels in CP model
A good way to see which matrices are used in umxCP is to run an example model and plot it.
All the shared matrices are in the model "top".
Matrices top$as
, top$cs
, and top$es
contain the path loadings specific to each variable on their diagonals.
So, to see the 'as' values, labels, or free states, you can say:
m1$top$as$values
m1$top$as$free
m1$top$as$labels
Labels relevant to modifying the specific loadings take the form "as_r1c1", "as_r2c2" etc.
The commonpathway loadings on the factors are in matrices top$a_cp
, top$c_cp
, top$e_cp
.
The common factors themselves are in the matrix top$cp_loadings
(an nVar * 1 matrix)
Less commonlymodified matrices are the mean matrix expMean
. This has 1 row, and the columns are laid out for each variable for twin 1, followed by each variable for twin 2.
So, in a model where the means for twin 1 and twin 2 had been equated (set = to T1), you could make them independent again with this line:
m1$top$expMean$labels[1,4:6] = c("expMean_r1c4", "expMean_r1c5", "expMean_r1c6")
mxModel()
umxSummaryCP()
, umxPlotCP()
. See umxACE()
for more examples of twin modeling.
plot()
and umxSummary()
work for all twin models, e.g., umxIP()
, umxCP()
, umxGxE()
, and umxACE()
. For a deepdive, see xmu_make_top_twin()
Other Twin Modeling Functions:
plot.MxModelTwinMaker()
,
power.ACE.test()
,
umxACE_cov_fixed()
,
umxACEcov()
,
umxACEv()
,
umxACE()
,
umxDoCp()
,
umxDoC()
,
umxGxE_window()
,
umxGxEbiv()
,
umxGxE()
,
umxIP()
,
umxRotate.MxModelCP()
,
umxSexLim()
,
umxSimplex()
,
umxTwinAddMeansModel()
,
umx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71  ## Not run:
# ========================================================
# = Run a 3factor Common pathway twin model of 6 traits =
# ========================================================
require(umx)
umx_set_optimizer("SLSQP")
data(GFF)
mzData = subset(GFF, zyg_2grp == "MZ")
dzData = subset(GFF, zyg_2grp == "DZ")
selDVs = c("gff", "fc", "qol", "hap", "sat", "AD")
m1 = umxCP("new", selDVs = selDVs, sep = "_T", nFac = 3,
dzData = dzData, mzData = mzData, tryHard = "yes")
# Shortcut using "data ="
selDVs = c("gff", "fc", "qol", "hap", "sat", "AD")
m1 = umxCP(selDVs = selDVs, nFac = 3, data=GFF, zyg="zyg_2grp")
# ===================
# = Do it using WLS =
# ===================
m2 = umxCP("new", selDVs = selDVs, sep = "_T", nFac = 3, optimizer = "SLSQP",
dzData = dzData, mzData = mzData, tryHard = "ordinal",
type= "DWLS", allContinuousMethod='marginals'
)
# =================================================
# = Find and test dropping of shared environment =
# =================================================
# Show all labels for C parameters
umxParameters(m1, patt = "^c")
# Test dropping the 9 specific and commonfactor C paths
m2 = umxModify(m1, regex = "(cs_.*$)(c_cp_)", name = "dropC", comp = TRUE)
umxSummaryCP(m2, comparison = m1, file = NA)
umxCompare(m1, m2)
# =======================================
# = Mixed continuous and binary example =
# =======================================
data(GFF)
# Cut to form umxFactor 20% depressed DEP
cutPoints = quantile(GFF[, "AD_T1"], probs = .2, na.rm = TRUE)
ADLevels = c('normal', 'depressed')
GFF$DEP_T1 = cut(GFF$AD_T1, breaks = c(Inf, cutPoints, Inf), labels = ADLevels)
GFF$DEP_T2 = cut(GFF$AD_T2, breaks = c(Inf, cutPoints, Inf), labels = ADLevels)
ordDVs = c("DEP_T1", "DEP_T2")
GFF[, ordDVs] = umxFactor(GFF[, ordDVs])
selDVs = c("gff","fc","qol","hap","sat","DEP")
mzData = subset(GFF, zyg_2grp == "MZ")
dzData = subset(GFF, zyg_2grp == "DZ")
# umx_set_optimizer("NPSOL")
# umx_set_mvn_optimization_options("mvnRelEps", .01)
m1 = umxCP(selDVs = selDVs, sep = "_T", nFac = 3, dzData = dzData, mzData = mzData)
m2 = umxModify(m1, regex = "(cs_r[35]c_cp_r[12])", name = "dropC", comp= TRUE)
# Do it using WLS
m3 = umxCP(selDVs = selDVs, sep = "_T", nFac = 3, dzData = dzData, mzData = mzData,
tryHard = "ordinal", type= "DWLS")
# TODO umxCPL fix WLS here
# label at row 1 and column 1 of matrix 'top.binLabels'' in model 'CP3fac' : object 'Vtot'
# Correlated factors example
data(GFF)
mzData = subset(GFF, zyg_2grp == "MZ")
dzData = subset(GFF, zyg_2grp == "DZ")
selDVs = c("gff", "fc", "qol", "hap", "sat", "AD")
m1 = umxCP("new", selDVs = selDVs, sep = "_T", dzData = dzData, mzData = mzData,
nFac = 3, correlatedA = TRUE, tryHard = "yes")
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.