Methodology
This project follows a ferry-ellis-mint-train-forecast-report pipeline adapted from RAnalysisSkeleton patterns, optimized for monthly time series forecasting with cloud migration as Phase 2 objective.
Data Source
Alberta Income Support Aggregated Caseload Data
- Public URL: Open Alberta - Income Support
- Temporal coverage: April 2005 to present (updated monthly by GoA)
- Structure: Monthly aggregates by geography, measure type (caseload, intakes, exits), and demographics
- Forecast target: Total active caseload count, 24-month horizon, monthly intervals
Pipeline Stages
| # | Pattern | Alias | Key Input | Key Output | Forbidden |
|---|---|---|---|---|---|
| 1 | Ferry | Ingestion | Open Alberta CSV / local file | Staging parquet / SQLite | Semantic transforms, renaming |
| 2 | Ellis | Transform | Ferry staging output | Analysis-ready parquet + CACHE-manifest | Model fitting, new data sourcing |
| — | (EDA) | (Advisory) | Ellis parquet | Reports & insight only | Producing consumed data artifacts |
| 3 | Mint | Prep | Ellis parquet + EDA decisions | forge/ parquet slices + forge_manifest.yml |
Model fitting, re-running Ellis |
| 4 | Train | Estimation | Mint artifacts only | Model .rds + model registry CSV |
Reading Ellis output directly |
| 5 | Forecast | Prediction | Train .rds + Mint full slice |
Forecast CSV + Quarto report | Refitting models |
| 6 | Report | Delivery | EDA + Train metrics + Forecast | Static HTML | New data transformations |
1. Ferry Pattern (Data Ingestion)
- Input: CSV from Open Alberta URL or local cache (
./data-private/raw/) - Process: Download if missing, validate schema, minimal SQL-like filtering (no semantic transforms)
- Output: Staging data in
./data-raw/derived/(parquet + CACHE DB if using DuckDB) - Validation: Row counts, date range checks, missing value inventory
2. Ellis Pattern (Data Transformation)
- Input: Ferry output (raw monthly aggregates)
- Process:
- Standardize column names (
janitor::clean_names) - Parse dates (YY-Mon format → proper Date objects)
- Clean numeric values (remove commas, handle suppressed cells)
- Create derived temporal features: fiscal year, month labels, lag features
- Filter to analysis-ready subset (e.g., Alberta total, caseload measure only)
- Standardize column names (
- Output: Analysis-ready dataset in
./data-raw/derived/+ CACHE-manifest.md - Quality checks: No missing dates in series, monotonic time index, documented factor levels
EDA (Exploratory Data Analysis) — Advisory, Not a Numbered Lane
EDA operates on Ellis output and produces analytical insight (reports, visualizations, stationarity tests) — not data artifacts consumed by downstream scripts. EDA findings are codified as documented decisions in Mint scripts.
- Objectives: Visualize trends, seasonality, structural breaks; diagnose stationarity
- Key outputs:
- Time series plot (2010-present for context, fiscal year overlays)
- ACF/PACF plots for AR/MA order selection
- Seasonal decomposition (STL or classical)
- Summary statistics table (mean, SD, growth rates by fiscal year)
- Format: Quarto report (
analysis/eda-2/eda-2.qmd) rendering to HTML - Relationship to Mint: EDA decisions are logged and referenced in Mint scripts (e.g.,
[EDA-001] Log transform: TRUE — confirmed by eda-2 g12)
3. Mint Pattern (Model-Ready Preparation)
- Input: Ellis parquet output + EDA-confirmed analytical decisions
- Process:
- Apply train/test split keyed to
focal_dateandbacktest_monthsfromconfig.yml - Apply log transform (if EDA-confirmed)
- Construct
tsobjects for train, test, and full series - Build xreg matrices for model tiers requiring exogenous regressors
- Apply train/test split keyed to
- Output: Apache Parquet data artifacts in
./data-private/derived/forge/+forge_manifest.ymlds_train/test/full.parquet— data frame slices (Train lane reconstructstsobjects from these)xreg_train/test/full/future.parquet— exogenous regressors withdatecolumn (cross-language)xreg_dynamic_*.parquet— 0-row schema placeholder for Tier 4
- Validation: Contract assertions (row counts, date boundaries, transform flags)
- Forbidden: Model fitting, new data sourcing, re-running Ellis logic
4. Train Pattern (Model Estimation)
- Input: Mint artifacts only (
ds_*.parquet,xreg_*.parquet,forge_manifest.yml) — never Ellis output directly- Reconstruct
tsobjects:ts(ds_train$y, start=c(year(min(date)), month(min(date))), frequency=12)
- Reconstruct
- Train/test split: Defined by Mint; uses all data through
focal_date - 24 monthsfor training; holds out last 24 months for backtesting - Model tiers (increasing complexity):
- Naive baseline: Last observed value propagated forward (benchmark)
- ARIMA: Auto-selected orders via
forecast::auto.arima()on log-transformed series - Subgroup disaggregation: Fit the same model specification (e.g., ARIMA) independently for each client-type caseload series. Client type is a classification of the social service (ETW, BFE, AISH, etc.), not a property of the individual — a person may transition between client types over time, but each client-type caseload series has its own dynamics. Tier 3 asks: does forecasting at the subgroup level and summing improve on forecasting the aggregate directly?
- ARIMA + time-varying predictor: Placeholder for economic indicator (e.g., oil price, unemployment rate) — structure only, real covariate TBD
- Model storage: Save fitted model objects as
.rdsin./data-private/derived/models/(R-native format; model objects cannot be stored as parquet); register metadata in model registry CSV withforge_hashlinking back toforge_manifest.yml - Performance metrics: RMSE, MAE, MAPE on held-out 24-month backtesting window
5. Forecast Pattern Pattern (Prediction)
- Input: Train model
.rds+ Mintds_full.parquetfor forward projection (reconstructts_fullon load) - Horizon: 24 months ahead from
focal_date - Outputs:
- Point forecasts + 80%/95% prediction intervals for each model tier
- Comparison table: all models side-by-side with performance diagnostics
- Format: CSV + Quarto report (
analysis/forecast-1/forecast-1.qmd)
6. Report Pattern (Deliverables)
- Deliverable: Static HTML combining EDA + model performance + 24-month forecast visualization
- Interactivity: Optional Plotly/htmlwidgets for hover details (keep simple; avoid heavy JS dependencies)
- Delivery: Manual publish to SharePoint/network drive (Phase 1); cloud-hosted web app with identity-provider auth (Phase 2; e.g., Azure Static Web Apps + Entra ID, Snowflake Streamlit)
Reproducibility Standards
- Version control: Git tracks all code, config, and documentation; data files in
.gitignore(too large, privacy) - Dependency management:
renv.lockfor R packages;conda/mambafor Python (if cloud migration requires) - Random seeds: Set
set.seed(42)before any stochastic operation; document in script headers - Configuration:
config.ymlstoresfocal_date, file paths, model hyperparameters (no hardcoded magic numbers) - Execution order:
flow.Rorchestrates full pipeline; each stage sources common functions from./scripts/ - Determinism: Forecasts are deterministic given fixed seed and package versions (no model randomness beyond seed)
Cloud Migration Strategy (Phase 2)
This repo is the cloud-agnostic on-prem core. Provider-specific adaptations live in fork repositories (caseload-forecast-demo-azure, caseload-forecast-demo-snowflake). The workspace also includes azure-aml-demo as a read-only reference for Azure ML patterns.
- R vs. Python: Keep data wrangling in R (ferry/ellis patterns stable); consider Python for model training if cloud platform integration is smoother (most cloud ML platforms have stronger Python SDKs)
- Compute allocation: Use affordable compute tiers for ferry/ellis; evaluate GPU necessity for complex models (unlikely for ARIMA). Examples: Azure ML compute instances, Snowflake warehouses
- Model registry: Transition from local model
.rdsfiles to a cloud model registry with MLflow tracking (e.g., Azure ML Model Registry, Snowflake Model Registry); data artifacts already in Parquet align natively with cloud-native tabular dataset APIs - Endpoint serving: Deploy best-performing model as a REST API or model-serving endpoint for programmatic access (e.g., Azure ML endpoints, Snowflake Model Serving, Power BI integration)
- Pipeline orchestration: Refactor
flow.Rinto a cloud ML pipeline with parameterized components — one pipeline step per pattern/lane (e.g., Azure ML Pipelines, Snowflake Tasks, or Airflow DAGs) - Scheduling: Monthly refresh via cloud-scheduled pipeline runs (replaces manual
Rscript flow.Rexecution)
Mint-Train-Forecast Lineage
The Mint, Train, and Forecast patterns form a versioned chain keyed by focal_date:
- Mint produces
forge_manifest.ymlwith split boundaries, transform flags, and row counts - Train records
forge_hashin the model registry CSV, linking each fitted model to its exact input data slice - Forecast inherits lineage through the model object it consumes
- Changing
focal_dateinconfig.ymlinvalidates all Mint, Train, and Forecast artifacts - This is the minimum viable versioning strategy for Phase 1; Phase 2 transitions to a cloud model registry with MLflow tracking (e.g., Azure ML Model Registry, Snowflake Model Registry)
Quality Assurance
- Unit tests:
testthatfor data validation functions (scripts/tests/) - Integration test:
flow.Rmust execute without errors on sample data - Peer review: Code changes reviewed by SDA team before merge to
mainbranch - Documentation: All functions have roxygen-style headers; non-obvious logic has inline comments