dat_gen | R Documentation |
This function generates the simulation data (exposure X, outcome Y, and potential mediators M).
For each subject i = 1, ..., N:
X_i \stackrel{i.i.d}{\sim} N(0, 1)
M_{i,v} = a_v X_i + e_{1_{i,v}}
, where e_{1_{i,v}} \stackrel{i.i.d}{\sim} N(0, 1), v = 1, ..., V
Y_i = X_i + \sum_v b_{1_{v}} M_{i,v} + \sum_v b_{2_{v}} X_i \times M_{i,v} + e_{2_{i}}
, where e_{2_{i}} \stackrel{i.i.d}{\sim} N(0, 1)
The first three M variables (M1,M2,M3) are set to be the true mediators (i.e., having non-zero a and b_1 coefficients), X x M1 is set to be the true exposure-by-mediator interaction term (i.e., having non-zero b_2 coefficients), and all other coefficients are set to be 0.
dat_gen(N, V, es, seed = 1234)
N |
sample size |
V |
number of potential mediators |
es |
effect size, representing the value of a, b1, b2 of the truth |
seed |
seed. Default is 1234. |
The resulting dataset has 3 lists: X, Y and M
dat_gen(100, 50, 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.