Skip to content

kidaufo/StateSpaceModel

Repository files navigation

State Space Modeling Playground

This project explores linear regression and state space models with a focus on practical forecasting workflows. The code originated from a semiconductor yield analysis engagement where online linear regression was the baseline and state space modeling provided better fidelity for drifting processes and level shifts. The repository now offers reproducible simulations, side-by-side comparisons, and lightweight visual artifacts.

What Is Included

  • SimulateRegressionModel.py — a Python script organised with #%% cells that synthesises several time-series scenarios, benchmarks online OLS against statsmodels' unobserved components models, and saves plots plus GIF animations.
  • SimulateRegressionModel.ipynb — a notebook view of the same workflow for interactive inspection.
  • artifacts/ — generated figures and animations (created after running the script or notebook).

Environment

The repository is configured for the uv package manager and ships with:

  • pyproject.toml describing runtime dependencies
  • uv.lock capturing resolved versions

Feel free to use another toolchain, but uv ensures fast, reproducible setups.

Quick Start

# Create the virtual environment and install dependencies
uv sync

# Regenerate synthetic data, plots, and GIF animations
uv run python SimulateRegressionModel.py

All artefacts are written to the artifacts/ directory. Existing files are overwritten on subsequent runs.

Working in a Notebook

Open SimulateRegressionModel.ipynb in VS Code or Jupyter. Each section mirrors the script's #%% cells. Running every cell will populate the same figures and metrics that the CLI workflow produces.

Legacy Material

The legacy/SimulateRegressionModel_old.ipynb notebook contains the earliest experiments, including Stan-based heavy-tailed models and alternative animation snippets. It is not maintained, but remains available for historical context.

About

State space modeling by KFAS, Stan and statsmodels.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published