Description Usage Arguments Value Author(s) Examples
Build correlated phenotypes
1 | build.cor.phe(pheno, corMtr, sdMtr = NULL, margin = 2, ...)
|
pheno |
a matrix or dataframe with the phenotypic information. |
corMtr |
a correlation matrix. |
sdMtr |
a matrix with the standard deviation,
e.g., if the number of dimensions is 2, then it is
≤ft(\begin{array}{cc} σ_{1} & 0 \\ 0 & σ_{2} \end{array}\right).
If it is NULL (default), generate it based on the data from |
margin |
a vector giving the subscript which the function will be
applied over.
E.g., for a matrix 1 indicates rows, 2 (default) indicates columns.
Where |
... |
not used. |
a matrix with correlated phenotypes.
Beibei Jiang beibei_jiang@psych.mpg.de
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | x1 <- rnorm(4000, mean = 5, sd = 10)
x2 <- rnorm(4000, mean = 10, sd = 30)
x <- matrix(cbind(x1, x2), ncol = 2)
# test original correlation
cor.test(x[, 1], x[, 2])
# correlation matrix
corM <- matrix(c(1, 0.6, 0.6, 1), ncol = 2)
# standard deviation matrix
sdM <- matrix(c(10, 0, 0, 30), ncol = 2)
# build correlation
x.new <- build.cor.phe(x, corM, sdM)
# check mean and standard deviation of new data set
apply(x.new, 2, mean)
apply(x.new, 2, sd)
# test correlation
cor.test(x.new[, 1], x.new[, 2])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.