R/simdata.R
simulate_data.RdThis function generates a simulated dataset for estimating
individualized treatment rules.
The outcome variable is assumed to follow equation (1) in
Section S.1.1 of the supplementary material.
simulate_data( N = 200, p = 20, K = 4, J = 4, propensity_func, main_func, interaction_func )
| N | the number of subjects. |
|---|---|
| p | the number of covariates. |
| K | the number of treatments. |
| J | the number of subject groups. |
| propensity_func | a user-defined function that calculates true propensity scores of
assigning each subject to each treatment. |
| main_func | a user-defined function that calculates main effects of
covariates on the outcome for each subject. |
| interaction_func | a user-defined function that calculates interaction effects of
of covariates and treatments on the outcome for each subject. |
A matrix containing the following columns of all subjects:
ID: IDs.
cluster: group memberships.
treatment: observed/assigned treatments.
reward: values of the (continuous) outcome.
feature_1, ..., feature_p: values of the p covariates.
interaction_1, ..., interaction_K: values of interaction effects
of covariates and each of the K treatments.
pi_1, ..., pi_K: propensity scores of assigning each of the K
treatments.
eps: values of random errors.
treatment_opt: optimal treatments.
reward_opt: outcome values of the optimal treatments.
pi_true: propensity scores of assigning the observed treatments.
pi_opt: propensity scores of assigning the optimal treatments.
pi.true for propensity_func,
mu.true for main_func,
and delta.true for interaction_func.
####################################### ## The simulated dataset in Section S.1.2 of ## the supplementary material for N=200 set.seed(0) simdata200 = simulate_data( N = 200, p = 20, K = 4, J = 4, propensity_func = pi.true, # equation (2) in Section S.1.1 main_func = mu.true, # equation (5) in Section S.1.2 interaction_func = delta.true # equation (6) in Section S.1.2 )