Example Models

pypomp includes several example models:

Dacca Model

pypomp.models.dacca.dacca(dt: float | None = 0.004166666666666667, nstep: int | None = None, gamma: bool = False) Pomp[source]

Creates a POMP model for the Dacca cholera data.

This function constructs a Partially Observed Markov Process (POMP) model for the Dacca cholera dataset. The model includes a stochastic process for the underlying disease dynamics and a measurement model for observed deaths.

Parameters:
  • dt (float, optional) – Time step size for the process model. Determines the number of sub-steps per observation interval for the process model.

  • nstep (int, optional) – Number of sub-steps per observation interval for the process model. If None, uses Euler discretization with the specified step size. nstep and dt cannot both be not None.

  • gamma (float) – Indicator for whether gamma white noise should be used in place of Gaussian noise. This corresponds to a large-population approximation of an overdispersed death process.

  • Parameters (Model)

  • ----------------

  • gamma – Recovery rate (duration of infectiousness).

  • epsilon (float) – Rate of waning of immunity for severe infections.

  • rho (float) – Rate of waning of immunity for inapparent infections.

  • m (float) – Cholera-specific mortality rate.

  • c (float) – Fraction of infections that lead to severe (clinically apparent) infection.

  • beta_trend (float) – Slope of the secular trend in transmission.

  • bs1-bs6 (float) – Seasonal transmission rates (B-spline coefficients).

  • sigma (float) – Environmental noise intensity.

  • tau (float) – Measurement error standard deviation.

  • alpha (float) – Non-linear transmission parameter.

  • delta (float) – Natural mortality rate.

  • S_0 (float) – Initial value parameters (IVPs) for the model state proportions.

  • I_0 (float) – Initial value parameters (IVPs) for the model state proportions.

  • Y_0 (float) – Initial value parameters (IVPs) for the model state proportions.

  • R1_0 (float) – Initial value parameters (IVPs) for the model state proportions.

  • R2_0 (float) – Initial value parameters (IVPs) for the model state proportions.

  • R3_0 (float) – Initial value parameters (IVPs) for the model state proportions.

  • omegas1-omegas6 (float) – Seasonal environmental reservoir parameters (B-spline coefficients for the log-reservoir).

Returns:

A POMP model object representing the Dacca cholera model.

Return type:

Pomp

SPX Model

pypomp.models.spx.spx()[source]

Creates a POMP model for the S&P 500 stock index data.

This function constructs a Partially Observed Markov Process (POMP) model for analyzing the S&P 500 stock index data. The model uses a stochastic volatility framework where the volatility follows a mean-reverting process and the log returns follow a normal random walk with time-varying variance.

Returns:

A POMP model object containing, among other things:

  • ys: S&P 500 log returns data.

  • theta: Model parameters including mu, kappa, theta, xi, rho, and V_0.

  • covars: Covariates used in the model. In this case, the log returns of the S&P 500 stock index at the previous time step.

Return type:

Pomp

UK Measles Model

class pypomp.models.measles.measlesPomp.UKMeasles[source]

Bases: object

static subset(units=None, clean=False)[source]

Return a subset of the UKMeasles data, filtered by the given units.

Parameters:
  • units (list of str, optional) – A list of unit names to subset the data by. If None, the entire dataset is returned.

  • clean (bool, optional) – If True, returns a copy of the data with suspicious values set to np.nan.

Return type:

A dictionary with the same structure as UKMeasles.data, but with the data subsetted to only include the given units.

static AK_mles() DataFrame[source]

MLEs from https://kingaa.github.io/sbied/measles/index.html

static Pomp(unit: list[str], theta: dict | list[dict], model: str = '001b', interp_method: str = 'shifted_splines', first_year: int = 1950, last_year: int = 1963, dt: float = 0.0027378507871321013, clean=False)[source]

Returns a Pomp object for the UK Measles data.

Parameters:
  • unit (list[str]) – Which unit to use. Currently only supports one unit.

  • theta (dict | list[dict]) – Parameters for the model. Can be a single dict or a list of dicts.

  • model (str) – The model to use. Can be “001b”, “001c”, “001d” or “002”.

  • interp_method (str) – The method to use to interpolate the covariates. Can be “shifted_splines” or “linear”.

  • first_year (int) – The first year of the data to use.

  • last_year (int) – The last year of the data to use.

  • dt (float) – The time step size to use for the model.

  • clean (bool) – If True, uses a copy of the data with suspicious values set to np.nan.

Returns:

A Pomp object for the UK Measles data.

Return type:

Pomp

Linear Gaussian Model

This module implements a linear Gaussian model for POMP.

pypomp.models.linear_gaussian.LG(T: int = 4, A: ~jax.Array = Array([[ 0.9800666 , -0.19866933],        [ 0.19866933,  0.9800666 ]], dtype=float32), C: ~jax.Array = Array([[1., 0.],        [0., 1.]], dtype=float32), Q: ~jax.Array = Array([[0.01  , 0.0002],        [0.0002, 0.01  ]], dtype=float32), R: ~jax.Array = Array([[0.1 , 0.01],        [0.01, 0.1 ]], dtype=float32), key: ~jax.Array = Array((), dtype=key<fry>) overlaying: [  0 111]) Pomp[source]

Initialize a Pomp object with the linear Gaussian model.

Parameters:
  • T (int, optional) – The number of time steps to generate data for. Defaults to 4.

  • A (jax.Array, optional) – The transition matrix. Defaults to the identity matrix.

  • C (jax.Array, optional) – The measurement matrix. Defaults to the identity matrix.

  • Q (jax.Array, optional) – The covariance matrix of the state noise. Defaults to the identity matrix.

  • R (jax.Array, optional) – The covariance matrix of the measurement noise. Defaults to the identity matrix.

  • key (jax.Array, optional) – The random key used to generate the data. Defaults to jax.random.key(111).

Return type:

A Pomp object initialized with the linear Gaussian model parameters and the generated data.