This repository contains the R scripts to reproduce the results of the Monte Carlo simulations of the study "Oversampling and Replacement Strategies in Propensity Score Matching: A Critical Review Focused on Small Sample Size in Clinical Settings" (https://doi.org/10.1186/s12874-021-01454-z).
Before running the scripts, please install the following R packages:
install.packages(
c("tidyverse", "Matching", "cobalt", "glue", "furrr",
"tictoc", "MASS", "doParallel", "see", "ggpubr", "knitr", "here",
"assertive", "usethis"),
dependencies = TRUE
)
The project contains the following files:
-
The file psm-oversampling.Rproj is the file of the Rstudio project.
-
The file sim_functions.R, that contains the functions used for the generation of the simulated datasets.
-
The file sim_setup.R, that contains the code used to simulate the scenarios for the main Monte Carlo simulations.
-
The file analysis_functions.R, that contains the functions implemented for the analysis on the simulated datasets in main simulations.
-
The file analysis_mc_sim.R, that contains the code used to run the analysis on the simulated datasets in main simulations.
-
The file sim_results.Rmd, an Rmarkdown file that can be used to display the results of the main simulations.
-
The file sim_functions_linear.R, that contains the functions used for the generation of the simulated datasets in secondary simulations.
-
The file sim_setup_linear.R, that contains the code used to simulate the scenarios for the secondary Monte Carlo simulations.
-
The file analysis_functions_linear.R, that contains the functions implemented for the analysis on the simulated datasets in secondary simulations.
-
The file analysis_mc_sim_linear.R, that contains the code used to run the analysis on the simulated datasets in secondary simulations.
-
The file sim_results_linear.Rmd, an Rmarkdown file that can be used to display the results of the secondary simulations.
The results of the main simulations can be replicated as follows:
-
Run the script sim_setup.R, which saves the simulated scenarios in a file named simulation_data_pop_10000000_n_10000.rda.
-
Run the script analysis_mc_sim.R, which stores the results of the simulations in a file named simulation_results_pop_1000000_n_10000.rda.
-
Knitr the sim_results.Rmd file to visualize the results of the simulations.
The results of the secondary simulations can be replicated as follows:
-
Run the script sim_setup_linear.R, which saves the simulated scenarios in a file named simulation_data_pop_10000000_n_10000_linear.rda.
-
Run the script analysis_mc_sim_linear.R, which stores the results of the simulations in a file named simulation_results_pop_1000000_n_10000_linear.rda.
-
Knitr the sim_results_linear.Rmd file to visualize the results of the simulations.