WorldDev.2026.1073278 / code /06_list_run_grid.R
cjerzak's picture
Upload 24 files
748dd7d verified
#!/usr/bin/env Rscript
file_arg <- grep("^--file=", commandArgs(FALSE), value = TRUE)
script_path <- sub("^--file=", "", file_arg[[1]])
source(file.path(dirname(normalizePath(script_path, mustWork = FALSE)), "common.R"))
set_replication_root()
args <- commandArgs(trailingOnly = TRUE)
grid_name <- if (length(args) > 0) args[[1]] else "main"
fund_sect_params <- c(
"ch_430", "ch_520", "ch_700", "ch_140", "ch_230", "ch_220",
"ch_310", "ch_160", "wb_330", "wb_410", "ch_110", "ch_210",
"wb_240", "wb_220", "ch_150", "ch_120", "wb_320", "wb_230",
"wb_110", "wb_120", "wb_310", "wb_160", "wb_140", "wb_210", "wb_150"
)
if (identical(grid_name, "within_unit")) {
x_approach_options <- c("unitFE", "did")
} else if (identical(grid_name, "main")) {
x_approach_options <- c(
"noX", "onlyX", "onlyFE", "onlyXandFE",
"withX", "withFE", "withXandFE"
)
} else {
stop("Unknown grid name: ", grid_name, ". Use 'main' or 'within_unit'.")
}
combos <- expand.grid(
X_approach = x_approach_options,
vision_backbone = "vt",
fund_sect_param = fund_sect_params,
RUN_MODE = c("MAIN", "ROBUST_NO_NTL", "ROBUST_BUFFER", "ROBUST_STRICT"),
stringsAsFactors = FALSE
)
combos <- combos[order(grepl("only", combos$X_approach), decreasing = TRUE), ]
combos$row_id <- seq_len(nrow(combos))
combos <- combos[, c("row_id", "X_approach", "vision_backbone", "fund_sect_param", "RUN_MODE")]
write.table(combos, row.names = FALSE, sep = ",", quote = FALSE)