This folder contains a suite of standalone Python simulations and a profiling utility that demonstrate how RobustiPy can be used on synthetic data to estimate effects, perform cross-validated model selection, and visualize robustness, as well as to profile runtime performance.
Each script runs from the command line (no notebook required) and saves figures to a ../figures directory.
-
sim1_vanilla.py
Basic OLS robustness demo on simulated data.- Data:
n=100observations; 1 main regressorx1+ 4 controlsz1…z4. - Outcome: Linear in
x1and controls with Gaussian noise. - Model:
OLSRobustwith bootstrapping (draws=1000) and 10-fold CV. - Output: SVG plots and summary table.
- Data:
-
sim2_longitudinal.py
Panel-style simulation with group-level heterogeneity.- Data: 1,000 groups × 10 obs each; correlated covariates from a factor model + shocks; group-specific coefficients.
- Model:
OLSRobustwithgroup='group',rescale_y=True,rescale_z=True. - Output: HQIC-based selection plots (PDF) and summary table.
-
sim3_constants.py
Multiple focal regressors with fixed coefficients.- Data:
n=1000;x1andz1as focal regressors,z2…z7as controls; correlated multivariate normal design. - Model:
OLSRobustwithdraws=1000, 10-fold CV. - Output: HQIC plots (PDF) and summary.
- Data:
-
sim4_binary.py
Binary outcome example using logistic-style robustness.- Data:
n=10,000; covariates from a factor-structured covariance; latent index thresholded at its median to formy1 ∈ {0,1}. - Model:
LRobustwithx=['x1'], controlsz1…z7,draws=1000, 10-fold CV. - Output: HQIC plots for several specs (PDF) and summary.
- Data:
-
sim5_multipley.py
Multiple dependent variables in a robust OLS framework.- Data:
n=1000; 5 covariates (x1…x5); 4 outcomes (y1…y4) generated from stacked β-vectors; 4 controls (z1…z4). - Model:
OLSRobustwith multiple outcomes,draws=1000, 10-fold CV, and rescaling of y/x/z. - Output: Plots (two-panel layout) showing robustness across specs, plus summary.
- Data:
-
time_profiler.py
Performance benchmarking tool for RobustiPy.- Purpose: Tests runtime under different numbers of controls, draws, and CV folds for both
OLSRobustandLRobust. - Features:
- Skips already-completed runs by tracking them in CSV files.
- Runs both OLS and logistic variants with the same synthetic data generation.
- Varies control set size (
CONTROL_VARSsubsets), draws (logarithmic sequence), and folds (FOLDS_LIST). - Handles segmentation faults gracefully by restarting the process.
- Output: Figures (PDF) and CSV logs of runtime per configuration.
- Purpose: Tests runtime under different numbers of controls, draws, and CV folds for both
Install RobustiPy and basic scientific Python packages:
pip install robustipy numpy pandas matplotlib