View source: R/simulate_demo_data.R
simulate_mr_mash_data | R Documentation |
mr.mash
.Function to simulate data from MN_{nxr}(XB, I, V)
, where X \sim N_p(0, Gamma)
,
B \sim \sum_k w_k N_r(0, Sigma_k)
, with Gamma
, w_k
, Sigma_k
, and V
defined by the user.
simulate_mr_mash_data(
n,
p,
p_causal,
r,
r_causal = list(1:r),
intercepts = rep(1, r),
pve = 0.2,
B_cor = 1,
B_scale = 1,
w = 1,
X_cor = 0,
X_scale = 1,
V_cor = 0
)
n |
scalar indicating the number of samples. |
p |
scalar indicating the number of variables. |
p_causal |
scalar indicating the number of causal variables. |
r |
scalar indicating the number of responses. |
r_causal |
a list of numeric vectors (one element for each mixture component) indicating in which responses the causal variables have an effect. |
intercepts |
numeric vector of intercept for each response. |
pve |
per-response proportion of variance explained by the causal variables. |
B_cor |
scalar or numeric vector (one element for each mixture component) with positive correlation [0, 1] between causal effects. |
B_scale |
scalar or numeric vector (one element for each mixture component) with the diagonal value for Sigma_k; |
w |
scalar or numeric vector (one element for each mixture component) with mixture proportions associated to each mixture component. |
X_cor |
scalar indicating the positive correlation [0, 1] between variables. |
X_scale |
scalar indicating the diagonal value for Gamma. |
V_cor |
scalar indicating the positive correlation [0, 1] between residuals |
A list with some or all of the following elements:
X |
n x p matrix of variables. |
Y |
n x r matrix of responses. |
B |
p x r matrix of effects. |
V |
r x r residual covariance matrix among responses. |
Sigma |
list of r x r covariance matrices among the effects. |
Gamma |
p x p covariance matrix among the variables. |
intercepts |
r-vector of intercept for each response. |
causal_responses |
a list of numeric vectors of indexes indicating which responses have causal effects for each mixture component. |
causal_variables |
p_causal-vector of indexes indicating which variables are causal. |
causal_vars_to_mixture_comps |
p_causal-vector of indexes indicating from which mixture components each causal effect comes. |
set.seed(1)
dat <- simulate_mr_mash_data(n=50, p=40, p_causal=20, r=5,
r_causal=list(1:2, 3:4), intercepts=rep(1, 5),
pve=0.2, B_cor=c(0, 1), B_scale=c(0.5, 1),
w=c(0.5, 0.5), X_cor=0.5, X_scale=1,
V_cor=0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.