Simulation Code for “Causal inference targeting a concentration index for studies of health inequalities”
This repository contains the R code used to reproduce the simulation results presented in the paper Ghasempour, M., de Luna, X. and Gustafsson, P.E. (2024).“Causal inference targeting a concentration index for studies of health inequalities.”
The simulation evaluates the performance of the proposed estimators under different model specifications.
The repository includes the following R scripts:
- sim_par_job.R – Main simulation script. Runs the simulations for a given sample size and saves the output files.
- contrast_sim_utility.R – Contains supporting functions required by the main simulation script.
- post_processing.R – Processes and summarizes the simulation results into separate CSV files.
-
Ensure that the files
sim_par_job.Randcontrast_sim_utility.Rare located in the same directory. -
Open R (or RStudio) and set the working directory to the folder containing these files:
setwd("path/to/your/folder") -
To run the simulation, open the file
sim_par_job.R. Inside the script, specify:path <- "path/to/save/results/" n <- 1000 r <- 1000
Then run:
source("sim_par_job.R")The simulation results will be generated and stored in the specified directory.
-
When the simulation has finished, open the post-processing script and specify the same sample size
nand the number of replicationsrused in the simulation.n <- 1000 r <- 1000
After setting
nandr, run:source("post_processing.R")This script creates separate CSV files containing the summarized results for:
-
G(0)
-
G(1)
-
G(2)
-
and the contrasts between them.
The resulting CSV files correspond to the tables reported in the paper.
-
-
All required R packages should be installed prior to running the code. The list of packages is provided at the beginning of each script.
-
The results are automatically saved in the directory specified by the user in the
pathvariable.
If you use this code, please cite the associated paper:
Ghasempour, M., de Luna, X., & Gustafsson, P. E. (2024).
Causal inference targeting a concentration index for studies of health inequalities.
arXiv:2410.08849