# Finance Causality Lab: Methods, Assumptions and Limitations

A working educational experiment built for Varun Chopra's portfolio. It applies **mediation, confounding and collider-bias concepts** to simplified financial-services scenarios. It is not a demonstration of an approved bank model, empirical findings, production risk scoring or a deployed causal-discovery algorithm.

## Purpose

A credit-risk analyst may observe that two financial indicators move together. The relationship alone does not identify a causal driver. This lab lets visitors choose a **known, stipulated directed acyclic graph** and generate synthetic observations under that graph, then compare:

- The raw Pearson correlation between `X` and `Y`.
- The partial correlation `r(X,Y | M)` after adjusting both variables linearly for `M`.
- A toy structural **what-if intervention**, where an input is changed while the other exogenous random shocks are held fixed.

**Important distinction:** Adjusting for a variable in an observational dataset is not the same as intervening on that variable. The program knows the causal structure because the visitor selected it, not because it inferred it from the data.

## The Three Financial Examples

All measures are **unitless synthetic scores**. They are not real interest-rate changes, borrower risk scores, actual arrears measures, probabilities of default or loan outcomes.

Let `ε1`, `ε2`, `ε3` be mutually independent draws from a standard normal distribution, `a` the assumed link coefficient (default `0.70`), and `σ` the standard deviation of added noise (default `1.00`).

### 1. Chain: Borrowing-Cost Pressure → Payment Burden → Repayment Stress

- `X = ε1` : borrowing-cost pressure index.
- `M = a X + σ ε2` : modelled debt-service or payment-burden index.
- `Y = a M + σ ε3` : modelled repayment-stress index.

The *only* assumed pathway from `X` to `Y` runs through `M` in this simplified model. Their raw sample correlation should generally be positive. Adjusting for `M` should move the correlation toward zero as sample size grows. Neither this statistical pattern nor the synthetic data establishes that real changes in borrowing costs have this structure.

**Toy intervention:** Holding exogenous shocks fixed and increasing `X` by `δ` yields `ΔM = a δ` and `ΔY = a² δ`.

### 2. Fork: Credit Utilisation ← Income Volatility → Repayment Stress

- `M = ε1` : income-volatility index.
- `X = a M + σ ε2` : credit-utilisation index.
- `Y = a M + σ ε3` : repayment-stress index.

`M` is the assumed common cause. Even though `X` and `Y` are correlated, there is **no causal arrow from `X` to `Y`** in this demonstration. Adjusting for `M` should reduce their sample correlation toward zero.

**Toy intervention:** Increasing `M` by `δ` yields `ΔX = a δ` and `ΔY = a δ`.

### 3. Collider: Credit Utilisation → Review Priority Score ← Historical Arrears Signal

- `X = ε1` : credit-utilisation index.
- `Y = ε2` : historical-arrears index.
- `M = a X + a Y + σ ε3` : review-priority score.

`X` and `Y` are deliberately generated independently. They both influence `M`, which makes `M` a common *effect* (a collider). Adjusting for the review score can induce a negative association between `X` and `Y`. In a real lending dataset, those indicators may already be related, and selection processes may be much more complex. The experiment illustrates a mathematical possibility, not an assessment of any institution's review procedures.

**Toy intervention:** Increasing `X` by `δ` yields `ΔM = a δ`, `ΔY = 0`. Historical arrears does not change in response to an intervention on current utilisation in this particular three-variable model.

## How the Calculations Work

1. Generate a seeded pseudo-random sequence using the Mulberry32 generator. Transform uniform samples into standard-normal draws with Box-Muller. This gives repeatable samples for the same settings and seed.
2. Use the selected linear structural equations to generate `(X, M, Y)` for `n` synthetic observations.
3. Compute sample Pearson correlation `r(X,Y)` by centring the variables and dividing their covariance by the product of standard deviations.
4. Regress `X` on `M` (including an intercept), regress `Y` on `M` (including an intercept), and correlate the two residual vectors. This is the sample partial correlation `r(X,Y | M)` in the single-adjustment-variable linear setup.
5. Plot raw observations and residualised values. The chart axes are in *relative standardised display units*; clipping extreme points for visual fit does not alter any numerical estimates.
6. Optionally show approximate two-sided p-values using Fisher's z transform, `atanh(r) × √(n − k − 3)` with `k = 0` or `1`, respectively, and an approximate standard-normal tail. These values are **descriptive approximations under Gaussian assumptions**; p-values do not prove causation or external validity.
7. For the separate hypothetical intervention, use the specified structural equations and current value of `a` to calculate deterministic differences under a user-selected index-point shock `δ`. The estimated sample correlations are *not* used to calculate these interventions.

## Interpreting the Experiment Correctly

- The **chain** and **fork** both imply `X ⟂ Y | M` (conditional independence), despite having different arrows. The observational correlation alone cannot uniquely distinguish them.
- The **collider** implies `X ⟂ Y` (unconditional independence) in the stipulated model, while conditioning on `M` can open an association.
- Small datasets and large noise can obscure the expected tendencies. The current result is from a sample, not a proof of a model property.
- Intervention outputs depend entirely on *correctly specified* causal equations. They are not reliable what-if forecasts for live portfolios, since there is no empirical estimation or validation.
- The demo does not measure actual regulatory capital, PD/LGD, fairness, affordability, arrears incidence, or bank profitability. There is no live customer information, financial-market feed or bank internal architecture.

## Reproducing the Experiment

The lab generates all observations in the browser from synthetic structural equations and a fixed pseudo-random seed. To reproduce its displayed results, select the same scenario, sample size, link strength, noise level and seed, then choose **Run Experiment**. The same settings produce the same observations and statistics.

The structural equations, Pearson correlation calculation, residualisation procedure and statistical assumptions are documented above for independent methodological review. The lab does not offer data or source-code download buttons.

This educational project is related in theme to causal-discovery research, but it must not be represented as a thesis result, an employer model or a production-level lending decision tool.
