dat_gen: Data generation function

View source: R/dat_gen.R

dat_genR Documentation

Data generation function

Description

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.

Usage

dat_gen(N, V, es, seed = 1234)

Arguments

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.

Value

The resulting dataset has 3 lists: X, Y and M

Examples

dat_gen(100, 50, 1)

ruiyangli1/XMInt documentation built on March 18, 2024, 12:13 p.m.