View source: R/sim_mediation_data.R
sim_mediation_data | R Documentation |
Simulate data for analysis.
sim_mediation_data(exp, sample_size, SC, bn = T)
exp |
For binary exposure, enter the exposure prevalence. For continuous exposure, enter the mean and sd of a normal distribution. |
sample_size |
Number of samples. |
SC |
A vector of parameters, in order of: b0, bw, bq, bs, a0, aw, aq, d0, dw, sigma_q, sigma_s, where Q=rnorm(sample_size,d0+dwW,sigma_q), S=rnorm(sample_size,a0+awW+aqQ,sigma_s), Y=ifelse(rnorm(sample_size,b0+bwW+bqQ+bsS,1)<0,0,1) |
confounders |
Confounder values. |
para=c(rep(-0.5,9),1,1)
dat1=sim_mediation_data(0.5,1000,para) #binary exposure
apply(dat1,2,mean) #the proportion of Y should not be too skew (nearly 0 or 1)
dat2=sim_mediation_data(c(0,1),1000,para) #continous exposure
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.