View source: R/simulate_phenotypes.R
make_phen | R Documentation |
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)
make_phen(effs, indep, vy = 1, vx = rep(1, length(effs)))
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)) |
Numeric array, simulated phenotype
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.