Pipeline Execution Guide

Purpose: Technical reference for the six-stage reproducible pipeline that transforms raw Alberta Income Support open data into 24-month caseload forecasts.


Overview

This pipeline follows a Ferry → Ellis → Mint → Train → Forecast → Report pattern, adapted from RAnalysisSkeleton. Each stage is a self-contained R/Quarto script orchestrated by flow.R.

Pipeline Architecture

flowchart LR
    subgraph "Data Ingestion"
        A["1-ferry.R<br/><i>Import</i>"]
    end
    subgraph "Transformation"
        B["2-ellis.R<br/><i>Clean & Shape</i>"]
    end
    subgraph "Advisory"
        C["eda-2.qmd<br/><i>Diagnostics</i>"]
    end
    subgraph "Modeling"
        D["3-mint-IS.R<br/><i>Prepare</i>"]
        E["4-train-IS.R<br/><i>Estimate</i>"]
        F["5-forecast-IS.R<br/><i>Predict</i>"]
    end
    subgraph "Delivery"
        G["report-1.qmd<br/><i>Report</i>"]
    end

    A --> B --> C
    B --> D --> E --> F --> G
    C -.->|informs| D

    style A fill:#4a90d9,color:#fff
    style B fill:#4a90d9,color:#fff
    style C fill:#f5a623,color:#fff
    style D fill:#7b68ee,color:#fff
    style E fill:#7b68ee,color:#fff
    style F fill:#7b68ee,color:#fff
    style G fill:#50c878,color:#fff

Pipeline Stages

# Stage Script Role Key Output
1 Ferry 1-ferry.R Import raw data from 4 equivalent sources (URL, CSV, SQLite, SQL Server) Staging SQLite database
2 Ellis 2-ellis.R Transform raw data into 11 analysis-ready tables (wide + long) Parquet files + SQLite + CACHE-manifest
— EDA eda-2.qmd Advisory — trend, seasonality, stationarity diagnostics Quarto HTML report (not in pipeline flow)
3 Mint 3-mint-IS.R Train/test split, log transform, regressor matrices forge/ Parquet slices + forge_manifest.yml
4 Train 4-train-IS.R Fit Tier 1 (Seasonal Naïve) and Tier 2 (ARIMA) models Model .rds objects + model_registry.csv
5 Forecast 5-forecast-IS.R Generate 24-month projections + backtest diagnostics Forecast CSVs + forecast_manifest.yml
6 Report report-1.qmd Assemble final HTML deliverable report-1.html

Lineage: A forge_hash in forge_manifest.yml links every model and forecast back to the exact data slice that produced it. Changing focal_date in config.yml invalidates all Mint/Train/Forecast artifacts downstream.

Dual format: Ellis outputs both Apache Parquet (primary — fast, columnar, cloud-ready) and SQLite (secondary — SQL exploration, portability).


Lane 1 — Ferry (Data Transport)

Pattern: Ferry (Zero semantic transformation)

Demonstrates that Income Support open data can be loaded from four equivalent sources, establishing source interchangeability:

  1. URL: Open Alberta API endpoint (production source)
  2. CSV: Local cached file (offline development)
  3. SQLite: Local database (fast access)
  4. SQL Server: Enterprise database (production alternative)

Permitted: Column name cleaning, column selection, skip header row. Forbidden: Factor recoding, value transformation, derived variables, filtering.

Output: Staging SQLite database with raw 5-column data (~50,000 rows).


Lane 2 — Ellis (Data Transformation)

Pattern: Ellis (Semantic transformation — first and only place raw data is reshaped)

Transforms the raw 5-column staging data into six tidy wide-format tables and one long-format companion for each, covering every demographic breakdown published in the open data.

Step Operation Rationale
Date parsing "05-Apr" → Date, derive year, month, fiscal_year, month_label Domain calendar needed by all downstream lanes
Value cleaning Strip commas, convert to numeric, suppressed "-" → NA Open Alberta publishes numbers as character strings
Factor recoding measure_type → ordered factor; abbreviate long measure labels Consistent taxonomy across all downstream analyses
Wide pivot Five demographic breakdowns pivoted from long → wide One row per date is the canonical analytical shape
Long companion Retain long format per table Required for ggplot faceting and stacked charts

Output: 11 analysis-ready tables (6 wide + 5 long) in Parquet and SQLite formats.


Lane 3 — Mint (Model-Ready Preparation)

Pattern: Mint (Prepares data slices consumed by ALL model tiers)

Codifies every analytical decision made during EDA into a versioned, reproducible artifact set. The Mint lane is the single source of truth for train/test split boundaries, log-transform decisions, and regressor matrices.

EDA Decision Log

ID Decision Evidence
EDA-001 Log transform: TRUE Variance stabilisation confirmed by EDA
EDA-002 Differencing: d = 1 expected Stationarity tests (ADF, KPSS)
EDA-003 Seasonal period: 12 Monthly data, Alberta fiscal year cycle
EDA-004 24-month backtest window Train/test split visualisation
EDA-005 Wide prediction intervals expected STL decomposition

Output: Parquet data slices in forge/ directory + forge_manifest.yml.


Lane 4 — Train (Model Estimation)

Pattern: Train (Fits model objects; never reads Ellis output directly)

Loads Mint artifacts, reconstructs time-series objects, fits two model tiers, and evaluates backtest accuracy on the held-out 24-month test window.

Tier Algorithm Description
Tier 1 Seasonal Naïve Repeats the prior year’s monthly pattern. Defines the performance floor.
Tier 2 ARIMA Auto-selected (p,d,q)(P,D,Q)[12] on log-transformed series. Captures trend and autocorrelation.
Tier 3 Subgroup disaggregation Deferred — structure present, not yet fitted
Tier 4 ARIMA + dynamic xreg Deferred — placeholder for economic indicators

Output: Fitted model .rds objects + model_registry.csv with backtest metrics (RMSE, MAE, MAPE).


Lane 5 — Forecast (24-Month Projections)

Pattern: Forecast (consumes Train model objects, produces prediction artifacts)

Generates 24-month forward projections and backtest diagnostics for all trained model tiers.

Forecast window: October 2025 – September 2027 (24 months from focal date).

Output: Forecast CSVs (point forecasts + 80%/95% prediction intervals) + forecast_manifest.yml.


Lane 6 — Report (Final HTML Deliverable)

Pattern: Report (reads all Forecast artifacts; produces self-contained HTML)

Assembles the complete forecast deliverable for stakeholders. The report does no new computation — all numbers come from pre-computed CSVs and manifests.

Report Sections:

  1. Executive Summary — projected trajectory, uncertainty, model comparison
  2. The Forecast — hero chart: 20-year history + 24-month ARIMA projection
  3. Key Forecast Numbers — point forecasts at +6, +12, +18, +24 months with 95% CI
  4. Model Comparison — faceted forecast: Seasonal Naïve vs ARIMA side by side
  5. Backtest Validation — actual vs fitted on held-out window; accuracy metrics
  6. Data Provenance — full lineage chain

Lineage Mechanism

The Mint, Train, and Forecast patterns form a versioned chain keyed by focal_date. A forge_hash (SHA-256 of the input Parquet file) links every downstream artifact to its exact data slice. Changing focal_date invalidates all Mint/Train/Forecast artifacts.