build.cor.phe: Build correlated phenotypes

Description Usage Arguments Value Author(s) Examples

Description

Build correlated phenotypes

Usage

1
build.cor.phe(pheno, corMtr, sdMtr = NULL, margin = 2, ...)

Arguments

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 pheno.

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 pheno has named dimnames, it can be a character vector selecting dimension names.

...

not used.

Value

a matrix with correlated phenotypes.

Author(s)

Beibei Jiang beibei_jiang@psych.mpg.de

Examples

 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])

SimPhe documentation built on May 1, 2019, 9:10 p.m.