make_phen: Create a phenotype using arbitrary number of known causal...

View source: R/simulate_phenotypes.R

make_phenR Documentation

Create a phenotype using arbitrary number of known causal inputs

Description

For a set of x variables and effect sizes for each variable (b) y is constructed such that y = Xb + e Given that the variance explained in y by X, is r^2 = sum(b * var(x) / (sqrt(x)*sqrt(y))) we can model e ~ N(0, 1 - r^2)

Usage

make_phen(effs, indep, vy = 1, vx = rep(1, length(effs)))

Arguments

effs

Array of beta values for each input. Leave the vx and vy values to default (=1) to allow effs to be equal to the correlation between y and each x

indep

Matrix of independent variables corresponding to effs

vy

The output variance of y. default=1

vx

The desired scaled variance of x. default=rep(1, length(effs))

Value

Numeric array, simulated phenotype

Examples

## Not run: 
g1 <- make_geno(1000, 0.5)
g2 <- make_geno(1000, 0.3)
x1 <- rnorm(1000)
x2 <- rnorm(1000)
y <- make_phen(effs=c(0.2, 0.1, 0.15, 0.4), cbind(g1, g2, x1, x2))


## End(Not run)

thomasbattram/usefunc documentation built on April 24, 2023, 1:46 p.m.