Skip to content

Commit b707616

Browse files
authored
Merge pull request #2 from quant-sci/update-docs
feat: enhance the documentation and change for furo template
2 parents 852a288 + a31a8cc commit b707616

32 files changed

Lines changed: 1216 additions & 256 deletions

.readthedocs.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
# Read the Docs configuration file
22
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
33

4-
# Required
54
version: 2
65

7-
# Set the OS, Python version, and other tools you might need
86
build:
97
os: ubuntu-24.04
108
tools:
119
python: "3.13"
1210

13-
# Build documentation in the "docs/" directory with Sphinx
1411
sphinx:
1512
configuration: docs/conf.py
1613

17-
# Optionally, but recommended,
18-
# declare the Python requirements required to build your documentation
19-
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
20-
# python:
21-
# install:
22-
# - requirements: docs/requirements.txt
23-
14+
python:
15+
install:
16+
- requirements: docs/requirements.txt

README.md

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,31 @@
1111
## Installation
1212

1313
```bash
14+
pip install dynaris
15+
# or
1416
uv add dynaris
1517
```
1618

19+
## Documentation
20+
21+
Full documentation is available at [dynaris.readthedocs.io](https://dynaris.readthedocs.io).
22+
1723
## Quickstart
1824

1925
```python
20-
from dynaris import LocalLevel, Seasonal, DLM
26+
from dynaris import LocalLevel, DLM
2127
from dynaris.datasets import load_nile
2228

2329
# Load data
2430
y = load_nile()
2531

26-
# Build a model by composing components
27-
model = LocalLevel(sigma_level=38.0, sigma_obs=123.0) + Seasonal(period=12)
28-
29-
# Fit, smooth, forecast
30-
dlm = DLM(model)
32+
# Build a local-level model and fit
33+
dlm = DLM(LocalLevel(sigma_level=38.0, sigma_obs=123.0))
3134
dlm.fit(y).smooth()
32-
fc = dlm.forecast(steps=12)
3335

34-
# Print summary
36+
# Forecast and plot
37+
fc = dlm.forecast(steps=10)
3538
print(dlm.summary())
36-
37-
# Single-figure overview
3839
dlm.plot(kind="panel")
3940
```
4041

@@ -43,7 +44,7 @@ dlm.plot(kind="panel")
4344
Build models by combining components with `+`:
4445

4546
```python
46-
from dynaris import LocalLinearTrend, Seasonal, Cycle, Autoregressive, Regression
47+
from dynaris import LocalLinearTrend, Seasonal, Cycle
4748

4849
model = (
4950
LocalLinearTrend(sigma_level=1.0, sigma_slope=0.1)
@@ -80,26 +81,14 @@ print(f"Log-likelihood: {result.log_likelihood:.2f}")
8081

8182
## Datasets
8283

83-
```python
84-
from dynaris.datasets import load_nile, load_airline, load_lynx, load_sunspots, load_temperature, load_gdp
85-
86-
y = load_airline() # 144 monthly obs, 1949-1960
87-
y = load_lynx() # 114 annual obs, 1821-1934 (~10-year cycle)
88-
y = load_sunspots() # 288 annual obs, 1700-1987 (~11-year cycle)
89-
y = load_temperature() # 144 annual obs, 1880-2023 (warming trend)
90-
y = load_gdp() # 319 quarterly obs, 1947-2026 (business cycle)
91-
```
92-
93-
## Notation
94-
95-
Dynaris follows the West & Harrison (1997) notation:
96-
97-
| Symbol | Code | Meaning |
98-
|--------|------|---------|
99-
| **G** | `model.G` / `system_matrix` | System (evolution) matrix |
100-
| **F** | `model.F` / `observation_matrix` | Observation (regression) matrix |
101-
| **W** | `model.W` / `evolution_cov` | Evolution covariance |
102-
| **V** | `model.V` / `obs_cov` | Observational variance |
84+
| Dataset | Loader | N | Frequency | Domain |
85+
|---------|--------|---|-----------|--------|
86+
| Nile river flow | `load_nile()` | 100 | Annual | Hydrology |
87+
| Airline passengers | `load_airline()` | 144 | Monthly | Transportation |
88+
| Lynx population | `load_lynx()` | 114 | Annual | Ecology |
89+
| Sunspot numbers | `load_sunspots()` | 288 | Annual | Astronomy |
90+
| Global temperature | `load_temperature()` | 144 | Annual | Climate |
91+
| US GDP growth | `load_gdp()` | 319 | Quarterly | Economics |
10392

10493
## License
10594

docs/_static/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.sidebar-logo img {
2+
max-width: 80px;
3+
}

docs/_static/logo.png

62.6 KB
Loading

docs/api/components.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ DLM Components
33

44
Composable building blocks for Dynamic Linear Models. Each function returns
55
a :class:`~dynaris.core.state_space.StateSpaceModel` that can be composed
6-
via the ``+`` operator.
6+
via the ``+`` operator. See :doc:`/user-guide/components` for usage guidance.
7+
8+
Trend
9+
-----
710

811
.. autofunction:: dynaris.dlm.components.LocalLevel
912

1013
.. autofunction:: dynaris.dlm.components.LocalLinearTrend
1114

15+
Periodic
16+
--------
17+
1218
.. autofunction:: dynaris.dlm.components.Seasonal
1319

20+
.. autofunction:: dynaris.dlm.components.Cycle
21+
22+
Other
23+
-----
24+
1425
.. autofunction:: dynaris.dlm.components.Regression
1526

1627
.. autofunction:: dynaris.dlm.components.Autoregressive
17-
18-
.. autofunction:: dynaris.dlm.components.Cycle

docs/api/core.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
11
Core Types
22
==========
33

4-
Fundamental data structures: state-space model, Gaussian state, result
5-
containers, and filter/smoother protocols.
4+
Fundamental data structures used throughout dynaris. These are the building
5+
blocks that filters, smoothers, and the DLM class operate on.
66

77
StateSpaceModel
88
---------------
99

10+
The central model representation. Holds the four system matrices (F, G, V, W)
11+
following West and Harrison (1997) notation. Returned by all component
12+
functions and composed via ``+``.
13+
1014
.. autoclass:: dynaris.core.state_space.StateSpaceModel
1115
:members:
1216
:show-inheritance:
1317

1418
GaussianState
1519
-------------
1620

21+
Represents a Gaussian belief about the state: a mean vector and covariance
22+
matrix. Used internally by the Kalman filter and smoother at each time step.
23+
1724
.. autoclass:: dynaris.core.types.GaussianState
1825
:members:
1926
:show-inheritance:
2027

2128
FilterResult
2229
------------
2330

31+
Container returned by the Kalman filter. Holds filtered state means,
32+
covariances, log-likelihood, and forecast errors for all time steps.
33+
2434
.. autoclass:: dynaris.core.results.FilterResult
2535
:members:
2636
:show-inheritance:
37+
:no-index:
2738

2839
SmootherResult
2940
--------------
3041

42+
Container returned by the RTS smoother. Holds smoothed state means and
43+
covariances for all time steps.
44+
3145
.. autoclass:: dynaris.core.results.SmootherResult
3246
:members:
3347
:show-inheritance:
48+
:no-index:
3449

3550
Protocols
3651
---------
3752

53+
Interfaces that filter and smoother implementations must satisfy. Useful
54+
for type checking and extending dynaris with custom algorithms.
55+
3856
.. autoclass:: dynaris.core.protocols.FilterProtocol
3957
:members:
4058

docs/api/datasets.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Datasets
2+
========
3+
4+
Built-in dataset loaders for examples and testing. Each function returns a
5+
pandas ``Series`` with an appropriate index. See :doc:`/user-guide/datasets`
6+
for a summary table.
7+
8+
.. autofunction:: dynaris.datasets.data.load_nile
9+
10+
.. autofunction:: dynaris.datasets.data.load_airline
11+
12+
.. autofunction:: dynaris.datasets.data.load_lynx
13+
14+
.. autofunction:: dynaris.datasets.data.load_sunspots
15+
16+
.. autofunction:: dynaris.datasets.data.load_temperature
17+
18+
.. autofunction:: dynaris.datasets.data.load_gdp

docs/api/dlm.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ DLM --- High-Level Interface
33

44
The :class:`~dynaris.dlm.api.DLM` class is the primary user-facing interface.
55
It wraps a :class:`~dynaris.core.state_space.StateSpaceModel` with convenient
6-
``fit``, ``forecast``, ``smooth``, ``plot``, and ``summary`` methods.
6+
methods for the full modeling workflow:
7+
8+
1. ``fit(y)`` --- run the Kalman filter
9+
2. ``smooth()`` --- run the RTS smoother
10+
3. ``forecast(steps)`` --- multi-step-ahead predictions
11+
4. ``plot(kind)`` --- visualize results
12+
5. ``summary()`` --- print model and fit information
13+
14+
Most users only need this class. The lower-level filter, smoother, and
15+
forecast functions are available for advanced use cases.
716

817
.. autoclass:: dynaris.dlm.api.DLM
918
:members:

docs/api/estimation.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
Parameter Estimation
22
====================
33

4-
Maximum likelihood estimation, EM algorithm, and model diagnostics.
4+
Maximum likelihood estimation, EM algorithm, residual diagnostics, and
5+
parameter transforms. See :doc:`/user-guide/estimation` for a guide on
6+
choosing between MLE and EM.
57

68
MLE
79
---
810

11+
Gradient-based optimization of the log-likelihood using JAX autodiff.
12+
Flexible: supports any differentiable parameterization via a user-defined
13+
``model_fn``.
14+
915
.. autofunction:: dynaris.estimation.mle.fit_mle
1016

1117
.. autoclass:: dynaris.estimation.mle.MLEResult
@@ -14,6 +20,9 @@ MLE
1420
EM Algorithm
1521
------------
1622

23+
Iterative variance estimation with guaranteed non-decreasing log-likelihood.
24+
Simpler setup than MLE --- just pass an initial model.
25+
1726
.. autofunction:: dynaris.estimation.em.fit_em
1827

1928
.. autoclass:: dynaris.estimation.em.EMResult
@@ -22,6 +31,8 @@ EM Algorithm
2231
Diagnostics
2332
-----------
2433

34+
Tools for checking model adequacy after fitting.
35+
2536
.. autofunction:: dynaris.estimation.diagnostics.standardized_residuals
2637

2738
.. autofunction:: dynaris.estimation.diagnostics.acf
@@ -33,6 +44,8 @@ Diagnostics
3344
Transforms
3445
----------
3546

47+
Map unconstrained parameters to positive values for variance estimation.
48+
3649
.. autofunction:: dynaris.estimation.transforms.softplus
3750

3851
.. autofunction:: dynaris.estimation.transforms.inverse_softplus

docs/api/filters.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
Kalman Filter
22
=============
33

4-
Forward filtering for linear-Gaussian state-space models.
4+
Forward filtering for linear-Gaussian state-space models. The Kalman filter
5+
processes observations sequentially, computing the posterior state distribution
6+
at each time step.
7+
8+
.. note::
9+
10+
Most users do not need to call these functions directly ---
11+
:meth:`DLM.fit() <dynaris.dlm.api.DLM.fit>` wraps the Kalman filter
12+
internally. These are available for advanced use cases requiring direct
13+
access to intermediate filter quantities.
514

615
.. autoclass:: dynaris.filters.kalman.KalmanFilter
716
:members:

0 commit comments

Comments
 (0)