-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_quantile_replication.R
More file actions
28 lines (24 loc) · 1.62 KB
/
Copy pathrun_quantile_replication.R
File metadata and controls
28 lines (24 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Slow, separately invoked replication of the legacy rqpd models.
arguments <- commandArgs(trailingOnly = FALSE)
file_argument <- grep("^--file=", arguments, value = TRUE)
if (length(file_argument) != 1L) stop("Execute this file with Rscript.", call. = FALSE)
script_path <- sub("^--file=", "", file_argument[[1L]])
project_root <- normalizePath(dirname(script_path), winslash = "/", mustWork = TRUE)
options(eco1400.project_root = project_root)
local_library <- Sys.getenv(
"ECO1400_R_LIBRARY",
unset = file.path(project_root, "environment", "R-library")
)
if (dir.exists(local_library)) .libPaths(c(normalizePath(local_library, winslash = "/"), .libPaths()))
source(file.path(project_root, "code", "00_config.R"), encoding = "UTF-8")
source(file.path(project_root, "code", "06_replicate_panel_quantiles.R"), encoding = "UTF-8")
source(file.path(project_root, "tests", "test_quantile_results.R"), encoding = "UTF-8")
config <- project_config(project_root)
processed_path <- file.path(config$paths$processed_dir, "fame_analysis_corrected.csv")
assert_pipeline(file.exists(processed_path), "Run run_all.R before the panel-quantile replication.")
data <- read.csv(processed_path, stringsAsFactors = FALSE, check.names = FALSE)
message("Running three rqpd models with 200 bootstrap replications each. This can take several minutes.")
result <- replicate_panel_quantiles(data, config, bootstrap_replications = 200L, base_seed = 1400L)
quantile_tests <- run_quantile_tests(result, config)
message("Panel-quantile replication completed: ", result$results_path)
message("Quantile tests passed: ", sum(quantile_tests$status == "PASS"), "/", nrow(quantile_tests))