Simulate Data for Average Treatment Effect (ATE) with Sample Weights
Source:R/simulate_ate_data_with_weights.R
simulate_ate_data_with_weights.Rd
Generates simulated data for a sample and a population to study average treatment effects (ATE), considering the presence of an effect modifier. The function simulates differences in the distribution of effect modifiers between the sample and the population without altering the treatment effect or the effect-modification. Weights are calculated to adjust for the distribution differences of the effect modifier between the sample and the population.
Usage
simulate_ate_data_with_weights(
n_sample = 10000,
n_population = 1e+05,
p_z_sample = 0.1,
p_z_population = 0.5,
beta_a = 1,
beta_z = 2.5,
beta_az = 0.5,
noise_sd = 0.5,
seed = NULL
)
Arguments
- n_sample
Integer, the size of the sample. Default is 10000.
- n_population
Integer, the size of the population. Default is 100000.
- p_z_sample
Numeric, the probability of the effect modifier in the sample. Default is 0.1.
- p_z_population
Numeric, the probability of the effect modifier in the population. Default is 0.5.
- beta_a
Numeric, the treatment effect. Default is 1.
- beta_z
Numeric, the coefficient of the effect modifier. Default is 2.5.
- beta_az
Numeric, the interaction term representing the effect modification of treatment by the effect modifier. Default is 0.5.
- noise_sd
Numeric, the standard deviation of the noise in the outcome variable. Default is 0.5.
- seed
Optional. An integer value for setting the seed to ensure reproducibility. Default is `NULL`, which does not set a seed.