What problem does it solve?
This Skill solves the difficulty of implementing a batched, high-performance Markov Regime-Switching (MRS) model in PyTorch while keeping parameters mathematically valid and training numerically stable.
Core Features & Use Cases
- Batched Hamilton Filter in PyTorch: Computes negative log-likelihood and filtered regime probabilities across many independent time series using tensor operations (e.g., batched matrix multiplications).
- Constraint-safe parameterization: Enforces strictly positive variances via exponential transforms and stochastic transition matrices via softmax parameterization so gradients remain valid.
- Identifiability via regime sorting: Applies post-training regime permutation by descending state means to resolve label-switching, enabling consistent Bull/Neutral/Bear interpretation.
- Numerical stability guardrails: Uses float64 guidance, epsilon padding, and log-likelihood safeguards to reduce underflow/overflow during likelihood updates.
Quick Start
Use the pytorch_hamiliton skill to implement a vectorized Hamilton filter MRS model for T time steps, N parallel asset series, and K regimes, then train it with gradient-based optimization using constrained parameters.