Description Usage Arguments Examples
Run a biometric model based on 1 generation of anchestors
1 2 |
vrs |
string vector with name of variables |
Alist |
list of OpenMx components for additive genetic model |
Tlist |
list of OpenMx components for twin/pregnancy environmental model |
Elist |
list of OpenMx components for unique environmental model |
D_M |
dataframe with mother identifiers |
D_F |
dataframe with father identifiers |
D_P |
dataframe with pregnancy identifiers and mz dummy |
D_C |
dataframe with pregnancy identifiers, mz dummy, covariates and variables to be analyzed |
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 | library(OpenMx)
data(D_5var) # Load example dataframe
nv = 5
vrs = paste0("Y", 1:nv)
D_C = D_5var[, c(vrs, "Pid", "mz", "female")]
D_P = D_5var %>%
group_by(Pid) %>%
summarise(Mid = unique(Mid),
Fid = unique(Fid),
mz = unique(mz)) %>%
ungroup() %>%
data.frame()
D_M = data.frame(Mid = unique(D_P$Mid))
D_F = data.frame(Fid = unique(D_P$Fid))
# Specify an "independent pathway" model
# Additive genetic model
lCA = mxMatrix("Full", nv, 1, T, 0.5, labF("lCA", nv, 1), name = "lCA")
lSA = mxMatrix("Diag", nv, nv, T, 0.5, labD("lSA", nv), name = "lSA")
VA = mxAlgebra(lCA%*%t(lCA) + lSA%*%t(lSA), name = "VA")
# Twin specific environmental model
lCT = mxMatrix("Full", nv, 1, T, 0.5, labF("lCT", nv, 1), name = "lCT")
lST = mxMatrix("Diag", nv, nv, T, 0.5, labD("lST", nv), name = "lST")
VT = mxAlgebra(lCT%*%t(lCT) + lST%*%t(lST), name = "VT")
# Unique environmental model
lCE = mxMatrix("Full", nv, 1, T, 0.5, labF("lCE", nv, 1), name = "lCE")
lSE = mxMatrix("Diag", nv, nv, T, 0.5, labD("lSE", nv), name = "lSE")
VE = mxAlgebra(lCE%*%t(lCE) + lSE%*%t(lSE), name = "VE")
# Mean model
B = mxMatrix("Full", nv, 2, T, 0, labF("b", nv, 2), name = "B")
X = mxMatrix("Full", 2, 1, F, 1, c("x1", "data.female"), name = "X")
My = mxAlgebra(B%*%X, name = "My")
Apars = list(lCA, lSA, VA)
Tpars = list(lCT, lST, VT)
Epars = list(lCE, lSE, VE)
Mpars = list(B, X, My)
fit = runMod1G(vrs, Apars, Tpars, Epars, Mpars, D_M, D_F, D_P, D_C)
summary(fit)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.