Quantitative Research · Theory & Methods

State-Space Model, Inference
& Crisis Early Warning

Mathematical foundations of latent_liquidity_quant — SVL-augmented state dynamics, DRD covariance, Sinkhorn OT particle filtering, online parameter learning, and the three-feature logistic warning pipeline.

Section 01

State-Space Model

Three latent factors drive all observables. The system is estimated daily via Sequential Monte Carlo, producing full posterior distributions rather than point estimates.

Latent state vector
$$ \mathbf{x}_t = [L_t,\; h_t,\; z_t]^\top \in \mathbb{R}^3 $$
$L_t$
Latent liquidity stress. Rises with funding pressure and spread widening. Primary crisis indicator; threshold at $L_t = 2$.
$h_t$
Log-volatility. Global vol scale is $e^{h_t/2}$. Long-run mean $\mu_h=0$ means $h_t=0$ corresponds to baseline daily vol ($\approx 1\%$/day SPY).
$z_t$
Correlation driver. $\rho_t = \tanh(z_t) \in (-1,1)$ maps $\mathbb{R}$ to a valid correlation. Increases with $L_t$ via the $\gamma$ coupling.

Transition Equations

State transitions
$$\begin{aligned} L_{t+1} &= \phi_L L_t + \beta_L e^{h_t/2} + \varepsilon_L,\quad \varepsilon_L \sim \mathcal{N}(0,\sigma_L^2) \\[4pt] h_{t+1} &= \mu_h + \phi_h(h_t-\mu_h) + \sigma_h\!\left(\rho_\text{lev}\varepsilon_t^\text{ret} + \sqrt{1-\rho_\text{lev}^2}\,\xi_t\right) \\[4pt] z_{t+1} &= \phi_z z_t + \gamma L_t + \varepsilon_z,\quad \varepsilon_z \sim \mathcal{N}(0,\sigma_z^2) \end{aligned}$$

The $\beta_L e^{h_t/2}$ coupling implements the liquidity-volatility spiral. Using $e^{h_t/2}$ (vol scale) rather than $e^{h_t}$ (variance) prevents explosive feedback during extreme events — a critical numerical stability choice.

Section 02

Stochastic Volatility with Leverage (SVL)

Equity markets exhibit a well-documented leverage effect: negative returns systematically precede volatility increases. The baseline SV model misses this, causing underestimation of vol during market dislocations.

SVL leverage mechanism
$$\varepsilon_t^\text{ret} = \frac{r_t^\text{SPY}}{\sigma_\text{spy}\cdot e^{h_t/2}}, \quad \rho_\text{lev} \in (-1,0), \quad \xi_t \sim \mathcal{N}(0,1)$$
Mechanism

When SPY returns are large and negative, $\rho_\text{lev}\varepsilon_t^\text{ret}$ is positive (since $\rho_\text{lev}<0$), pushing $h_{t+1}$ upward. Default: $\rho_\text{lev}=-0.731$. Constrained via $-\sigma(\tilde\rho)$. Validation: after SVL, DPF gives $h_\text{calm}\approx-0.6$, $h_\text{GFC}\approx+1.1$ — VIX 18 calm, VIX 30 at peak.

Section 03

DRD Return Covariance

The simple $\Sigma_t = e^{h_t}R(\rho_t)$ assigns identical variance to all assets. The Diagonal-Rotation-Diagonal (DRD) structure gives each asset its own baseline volatility.

DRD covariance
$$\Sigma_t = D_t R(\rho_t) D_t, \qquad D_t = \mathrm{diag}(\sigma_\text{spy},\sigma_\text{tlt},\sigma_\text{hyg})\cdot e^{h_t/2}$$ $$R(\rho_t) = (1-\rho_t)I_3 + \rho_t\mathbf{1}\mathbf{1}^\top, \quad \rho_t=\tanh(z_t)$$
$\sigma_\text{spy}=0.010$
$\approx$15.9% annualised baseline daily vol. VIX equation: $b_\text{vix}\approx\sigma_\text{spy}\sqrt{252}\times100\approx15$.
$\sigma_\text{tlt}=0.008$
$\approx$12.7% annualised. Treasury duration risk; lower than equity.
$\sigma_\text{hyg}=0.006$
$\approx$9.5% annualised. HY bonds have lower daily vol than equity despite higher credit risk.
Section 04

Data Inputs

SPY returns
Equity risk appetite. Enters $\Sigma_t$ via DRD; standardised return drives SVL leverage noise in $h_t$ transition.
TLT returns
Flight-to-quality proxy. Negative baseline correlation with SPY ($a_\text{corr}=-0.15$) reflects normal-period Treasury/equity dynamic.
HYG returns
High-yield credit — funding stress signal directly linked to $L_t$ via spread observation equation.
VIX
CBOE implied vol. Observed proxy for $h_t$: $\mathcal{N}(3+15e^{h_t/2}, 4)$. $h_t=0\Rightarrow\text{VIX}=18$; $h_t=2.5\Rightarrow\text{VIX}\approx56$.
HY Spread
ICE BofA OAS. Regressed on $L_t$: $\mathcal{N}(3.5+L_t, 0.023)$. Daily noise $\sigma=0.15\%$ reflects realistic HY market.
SPY/TLT Corr
30-day rolling Pearson correlation. $\mathcal{N}(-0.15+0.4\rho_t, 0.01)$. Rises toward 1 during systemic stress.
Section 05

Filter Architectures

Both filters maintain $N$ weighted particles: $p(\mathbf{x}_t\mid\mathbf{y}_{1:t})\approx\sum_i w_t^{(i)}\delta(\mathbf{x}_t-\mathbf{x}_t^{(i)})$.

Bootstrap Particle Filter (BPF)

$N=1000$, fixed hand-calibrated parameters, multinomial resampling when $\text{ESS}_t < N/2$. Stable and stationary — easier to calibrate, but cannot adapt to structural shifts.

Differentiable Particle Filter (DPF)

$N=500$, Sinkhorn OT resampling, online gradient-based parameter learning. Makes the filter differentiable with respect to $\bm\theta$.

Sinkhorn regularised OT ($\varepsilon=0.5$, 20 iterations)
$$\min_{P\in\Pi(\mathbf{w},\mathbf{u})}\langle P,C\rangle_F - \varepsilon H(P), \quad C_{ij}=\|\mathbf{x}^{(i)}-\mathbf{x}^{(j)}\|^2$$ $$K_{ij}=\exp(-C_{ij}/\varepsilon): \quad \mathbf{u}^{(k+1)}=\mathbf{w}\oslash(K\mathbf{v}^{(k)}), \quad \mathbf{v}^{(k+1)}=\mathbf{1}/N\oslash(K^\top\mathbf{u}^{(k+1)})$$

$P^\star(\mathbf{w})$ is smooth, so gradients $\partial\log p/\partial\bm\theta$ flow through resampling via TensorFlow autodiff.

BPF wins
Posterior Precision
Fixed params → stationary $L_t$. Mean CI 0.22 vs DPF 0.55. Tail prob AUC 0.726 vs 0.709.
DPF wins
Early Warning
Endogenous episode AUC 0.567 vs 0.500. Signal-to-noise 2.67 vs 2.21. Crisis/calm 340× vs 54×.
Key tradeoff
Bias-Variance
DPF adapts to crisis signatures (lower bias, higher variance). BPF fixed params regularise. DPF needs fixed-param SSM for forward simulation.
Section 06

DPF Online Parameter Training

Training objective
$$\mathcal{L}(\bm\theta)=-\log p(\mathbf{y}_{t-W:t}\mid\bm\theta)\approx-\sum_{s=t-W}^{t}\log\!\left(\tfrac{1}{N}\sum_i p(\mathbf{y}_s\mid\mathbf{x}_s^{(i)},\bm\theta)\right)$$
1
Rolling window
$W=120$ days, stride $U=60$. At each update point $t$, extract $\mathbf{y}_{t-120:t}$. For $t < W$: use hand-tuned defaults (burn-in).
2
DPF forward pass
Run Sinkhorn-resampled filter on window. Compute $\mathcal{L}$ and $\nabla_{\bm\theta}\mathcal{L}$ via TF auto-differentiation.
3
Persistent Adam
$\eta=5\times10^{-4}$, gradient clip norm 5.0, max 50 epochs/window. Persistent across windows — preserves momentum.
4
NaN/spike safety
Loss spike (3× recent median) or NaN triggers rollback to last valid checkpoint. <5% of windows affected.
5
Causal store
$\bm\theta_t$ only used for inference at $s\geq t$ — strict no-lookahead guarantee.
results/trained_params/dpf_learned_params.npz

10 learnable parameters. Constrained via: sigmoid ($\phi_\cdot$), softplus ($\beta,\gamma,\sigma$), negative sigmoid ($\rho_\text{lev}$).

Section 07

60-Day Crisis Probability

The filtering posterior is extended into a 60-day Monte Carlo simulation. DPF uses a separate fixed-parameter SSM — preventing parameter drift from inflating calm-period crisis probabilities.

Step 01
Resample
Draw particles from $p(\mathbf{x}_t\mid\mathbf{y}_{1:t})$ weighted by $\{w_t^{(i)}\}$.
Step 02
Propagate
Run each particle forward $H=60$ steps via fixed-param SSM. Track simulated drawdown per particle.
Step 03
Score
Apply calibrated logistic model $f_{\bm\beta}(\hat{L},\Delta\hat{L},D)$ each step.
Step 04
Rescale
Average over particles + horizon, subtract neutral baseline $p_0\approx0.42$, clip to $[0,1]$.
Neutral-baseline rescaling
$$P_\text{raw}(t)=\frac{1}{N_\text{sim} H}\sum_{i,h}p_{\bm\beta}^{(i,h)},\qquad P_\text{crisis}(t)=\mathrm{clip}\!\left(\frac{P_\text{raw}-p_0}{1-p_0},\,0,\,1\right)$$

Results: DPF 340× (GFC 0.784, calm 0.002), BPF 54× (GFC 0.788, calm 0.014). Smoothed with 10-day rolling average post hoc.

Section 08

Three-Feature Warning Calibration

A logistic layer converts posterior states into 30-day pre-crisis warning probabilities. COVID and SVB are held out from all training.

Features and warning model
$$f_1=\frac{\hat{L}_t-\mu_L^{(t)}}{\sigma_L^{(t)}},\quad f_2=\frac{\Delta_5 f_1-\mu_\Delta^{(t)}}{\sigma_\Delta^{(t)}},\quad f_3=\frac{\max P_s - P_t}{\max P_s}$$ $$P(\text{warning})=\sigma(\beta_0+\beta_1 f_1+\beta_2 f_2+\beta_3 f_3)$$

Fitted Weights

FeatureDPFBPFSign interpretation
$f_1$ — L level+0.774+0.703Higher stress → higher warning ✓
$f_2$ — dL momentum−0.295−0.254Momentum peaks before level; most discriminative early
$f_3$ — drawdown+0.566+0.581Deeper drawdown → elevated warning ✓
$\beta_0$ — intercept−0.358−0.299Neutral output $p_0\approx0.41$–$0.43$

Predict → Calibrate → Predict

1
First predict pass
Generate posteriors. Crisis prob from heuristic threshold.
python main.py predict --filter dpf
2
Calibrate
Fit logistic on $f_1,f_2,f_3$. Save to .pkl.
python main.py calibrate --filter dpf
3
Second predict pass
Forward simulation with calibrated scorer. Final crisis_prob stored.
python main.py predict --filter dpf
Section 09

Parameter Reference

Learnable Transition Parameters

SymbolDefaultConstraintInterpretation
$\phi_L$0.95sigmoidStress autocorrelation — high persistence
$\beta_L$0.08softplusVol-to-stress; uses $e^{h/2}$ not $e^h$
$\mu_h$0.0unconstrainedLong-run log-vol; baseline vol scale = 1
$\phi_h$0.98sigmoidVol persistence, $\approx$34-day half-life
$\phi_z$0.95sigmoidCorrelation-state persistence
$\gamma$0.30softplusStress to correlation coupling
$\sigma_L$0.05softplusStress process noise
$\sigma_h$0.15softplusLog-vol diffusion
$\sigma_z$0.05softplusCorrelation noise
$\rho_\text{lev}$−0.731$-\sigma(\cdot)$SVL leverage — vol rises with neg. returns

Fixed Observation Parameters

ParameterValueObservableRationale
$a_\text{vix}$, $b_\text{vix}$3.0, 15.0VIX$h=0\Rightarrow\text{VIX}=18$; $b\approx\sigma_\text{spy}\sqrt{252}\times100$
$\sigma_\text{vix}$2.0VIXDaily measurement noise
$a_\text{sp}$, $b_\text{sp}$3.5, 1.0HY SpreadCalm OAS $\approx$ 350bps; +100bps per $L_t$ unit
$\sigma_\text{sp}$0.15HY SpreadDaily spread noise ≈ 15bps
$a_\text{corr}$, $b_\text{corr}$−0.15, 0.4CorrNegative baseline (SPY/TLT flight-to-quality)
$\sigma_\text{corr}$0.1CorrRolling-corr daily noise
$\sigma_\text{spy}$0.010SPY return$\approx$15.9% annualised
$\sigma_\text{tlt}$0.008TLT return$\approx$12.7% annualised
$\sigma_\text{hyg}$0.006HYG return$\approx$9.5% annualised