This repository reproduces the simulated case study from A Machine Learning Approach Based on Survival Analysis for IBNR Frequencies in Non-Life Reserving. The private real-data case study is not included.
This repository uses three independent targets pipelines. The split is required because the production cloud cannot provide torch, tensorflow, or keras.
| Pipeline | Models | Output |
|---|---|---|
_targets_cloud.R |
COX, XGB, DGP, CL, CLMplus-ac, CLMplus-apc | results/cloud/cloud_scores.csv |
_targets_local_nn_mw18.R |
ReSurv NN, MW18 | results/local/local_scores.csv |
_targets_eta_study.R |
COX over nine eta values | results/eta_study/eta_scores_long.csv |
CL is created only by Score_Reserving(..., chain_ladder = TRUE) in the cloud stream. The cloud stream also requests clmplus_benchmark = c("ac", "apc") for the CLMplus-ac and CLMplus-apc literature benchmarks. The local and eta pipelines use chain_ladder = FALSE and do not request CLMplus benchmarks. The eta output is never part of the main merge.
Create the immutable job grid once:
Rscript scripts/make_simulation_grid.RThe default grid contains alpha--epsilon, 20 replications, four years, exposure 200, and reproducible simulation/fitting seeds. To preserve the legacy publication datasets, sim_seed equals rep_id within every scenario; fitting seeds are generated once and stored in the shared grid. Both main pipelines read results/simulation_grid.csv; neither pipeline generates seeds. Enable the supported zeta and eta simulator scenarios with:
RESURV_INCLUDE_OPTIONAL_SCENARIOS=true Rscript scripts/make_simulation_grid.RImportant overrides are RESURV_SCENARIOS, RESURV_REPS, RESURV_MASTER_SEED, RESURV_YEARS, RESURV_PERIOD_EXPOSURE, and RESURV_PERIOD_FREQUENCY.
Install targets, data.table, xgboost, clmplus, and the local ReSurv package.
Cloud SLURM execution additionally needs crew and crew.cluster. Local execution needs torch, keras, and tensorflow; configure the Keras backend before starting the local pipeline.
The previous Bayesian optimizer dependency has been removed from the production simulation pipelines. Hyperparameters are now selected with direct ReSurvCV() over small deterministic publication grids.
Cloud, using the PSL-style crew/SLURM controller:
RESURV_USE_SLURM=true Rscript scripts/run_cloud.RUseful scheduler overrides are RESURV_SLURM_PARTITION, RESURV_SLURM_SCRIPT_LINES, RESURV_CLOUD_WORKERS, RESURV_CLOUD_MEMORY_GB, and RESURV_CLOUD_TIME_MIN. Grid creation and aggregation remain in the main process; simulation branches are restartable targets. Every process forces data.table, BLAS, OpenMP, and XGBoost to one thread.
For a non-SLURM cloud-side run, leave RESURV_USE_SLURM=false.
Run the neural models locally:
Rscript scripts/run_local_nn_mw18.RRun the separate eta sensitivity study:
Rscript scripts/run_eta_study.RMerge only the two main streams:
Rscript scripts/merge_cloud_local_results.RThis writes results/merged/all_scores.csv and results/merged/score_summary.csv and rejects local or duplicate CL rows.
Each pipeline has a separate targets store (_targets_cloud, _targets_local_nn_mw18, and _targets_eta_study) so it can resume without invalidating the others.
Run these before production:
Rscript scripts/smoke_test_cloud.R
Rscript scripts/smoke_test_local.R
Rscript scripts/smoke_test_eta_study.R
Rscript scripts/smoke_test_merge.RSmoke tests use one alpha row, four years, exposure 100, and isolated _smoke stores/files. XGB uses two-fold direct ReSurvCV() with 20 rounds. NN uses two-fold direct ReSurvCV() with three epochs. MW18 uses the small deterministic validation grid with three epochs. The tests call tar_validate(), print tar_manifest(), run tar_make(), and assert model membership and stream separation. Publication filenames are not overwritten by smoke tests.
Normal runners use publication controls automatically. RESURV_SMOKE=true is reserved for test runs; unset it for publication runs.
XGB uses five-fold direct ReSurvCV() over 18 candidates:
eta = c(0.03, 0.08, 0.15)max_depth = c(1, 2, 3)min_child_weight = c(1, 10)subsample = 0.85lambda = 1alpha = 0nthread = 1
XGB CV uses 500 tuning rounds and early stopping after 50 rounds. The final XGB fit uses 1,000 rounds and early stopping after 150 rounds.
ReSurv NN uses five-fold direct ReSurvCV() over 12 candidates:
- architectures
c(8),c(16), andc(8, 4) - activations
reluandselu - optimizer
Adam - learning rates
0.003and0.01 xi = 0,eps = 0- CV early stopping enabled with patience 25
NN CV uses 100 epochs. The final NN fit uses 1,000 epochs, early stopping, and patience 300.
MW18 uses a standalone mw18_fit()/predictReserve.mw18() implementation with artificial valuation-date validation at lag 1 over a deterministic three-candidate grid: 5, 10, and 20 neurons with one hidden layer. MW18 CV uses 50 epochs; the final fit uses 500 epochs.
The eta study reuses the first alpha grid seed and fits COX at seq(0.1, 0.9, 0.1) without tuning.
The former ERDA scripts, manual chain-ladder implementation, historical cross-validation outputs, and legacy SLURM wrappers have been removed from this branch. They remain available in the Git history; this working tree contains only the targets-based pipeline.