View source: R/emxBehaviorGenetics.R
emxCholeskyComponent | R Documentation |
This function creates all the objects needed for a Cholesky component.
emxCholeskyComponent(x, xname, xvalues, xfree, h=2, hname=paste0('H', xname), hvalues, hlabels)
x |
character vector. The base names of the variables used for the matrix with no repetition for twins (x, y, z not x1, y1, z1, x2, y2, z2). |
xname |
character. Name of the component matrix. |
xvalues |
numeric vector. Values of the component matrix. |
xfree |
logical vector. Whether each element of the component matrix is freely estimates. |
h |
numeric. The number of variables for the relatedness matrix, i.e. the number of critters with relationships |
hname |
character. Name of the relatedness matrix. |
hvalues |
numeric vector. Values for the relatedness matrix. |
hlabels |
character vector. Labels for the relatedness matrix. |
This function is a combination of emxCholeskyVariance, emxRelatednessMatrix, and emxKroneckerVariance.
A list with elements (1) the lower triangular matrix for the Cholesky, (2) the full positive definite variance matrix, (3) the relatedness matrix, and (4) the Kronecker product of the variance matrix and the relatedness matrix.
emxGeneticFactorComponent
# Create an ACE model in 22 lines require(EasyMx) require(OpenMx) data(twinData) twinVar = names(twinData) selVars <- c('ht1', 'bmi1','ht2','bmi2') mzdzData <- subset(twinData, zyg %in% c(1, 3), c(selVars, 'zyg')) mzdzData$RCoef <- c(1, NA, .5)[mzdzData$zyg] nVar = length(selVars)/2 x <- paste0('x', 1:nVar) acomp <- emxCholeskyComponent(x, 'A', hvalues=c(1, .5, 1), hlabels=c(NA, 'data.RCoef', NA)) ccomp <- emxCholeskyComponent(x, 'C', hvalues=c(1, 1, 1)) ecomp <- emxCholeskyComponent(x, 'E', hvalues=c(1, 0, 1)) totalVar <- mxAlgebra(AKron + CKron + EKron, 'V', dimnames=list(selVars, selVars)) totalMean <- emxMeans(selVars, type='twin') expect <- mxExpectationNormal(totalVar$name, totalMean$name) fitfun <- mxFitFunctionML() comlist <- c(acomp, ccomp, ecomp, list(totalVar, totalMean, expect, fitfun)) model <- mxModel('model', comlist, mxData(mzdzData, 'raw')) ## Not run: run2 <- mxRun(model) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.