Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Grids and stochastic processes

A grid defines a variable’s numerical outcome space. A stochastic process defines both an outcome grid and its transition mechanism.

Lifecycle and categorical grids

The explicit ordered flag matters: interpolation and comparison may use ordering only when the economics declares it.

Continuous grids

ClassDeclaration
LinSpacedGrid(start, stop, n_points)Uniform linear spacing
LogSpacedGrid(start, stop, n_points)Uniform spacing after log transform
IrregSpacedGrid(points)Explicit sorted nodes
PiecewiseLinSpacedGrid(start, stop, breakpoints, points_per_segment)Linear segments with independently controlled density
PiecewiseLogSpacedGrid(start, stop, breakpoints, points_per_segment)Log-spaced segments
GridBreakpoint(value, owner=...)Interior boundary and which adjacent segment owns it
ConditionalAction(grid, active_when, inactive_value)Action grid used only under some discrete-action values

A grid’s start, stop and breakpoint values are floats: an int is stored as a Python float, and a JAX scalar is refused. n_points and points_per_segment are Python integers; a JAX array count is refused, since a count fixes an array shape. Write bounds as numbers, not arrays, so that dataclasses.replace and equality work on the stored values.

Piecewise grids control grid density at known locations. They do not declare an economic budget kink to a specialized solver. Use case pieces or a piecewise-affine schedule for that structure.

ConditionalAction wraps a continuous action grid. The action ranges over the grid where every discrete action named in active_when takes one of its listed values, and takes inactive_value, which must be a node of the grid, everywhere else. See Conditional actions.

Stochastic processes

Place process instances in states and omit their names from state_transitions:

ProcessMeaning
UniformIIDProcessIID uniform draws
NormalIIDProcessIID normal draws
JointNormalIIDProcessNamed IID Gaussian shocks sharing a covariance matrix
LogNormalIIDProcessIID log-normal draws
NormalMixtureIIDProcessIID normal-mixture draws
TauchenAR1ProcessAR(1) discretized by Tauchen
RouwenhorstAR1ProcessAR(1) discretized by Rouwenhorst
TauchenNormalMixtureAR1ProcessMixture innovation with Tauchen-style discretization

TauchenAR1Process.on_nodes(nodes=..., rho=None, sigma=None, mu=0.0) uses supplied physical nodes with midpoint probability bins and open tails. The axis is fixed; unspecified law parameters are runtime operands and unit-root persistence is allowed. nodes is a one-dimensional NumPy or JAX array, as are IrregSpacedGrid(points=...) and DiscreteGrid(values=...); lists and tuples are refused. Nodes must be finite and strictly increasing at the working precision. Ordinary Tauchen construction still places its own stationary grid.

The factory accepts transition_rule="midpoint" (default), "density" (row-normalized normal densities at state nodes, computed in log space), or "innovation_quadrature" (standardized innovation weights mapped linearly to adjacent state nodes, with targets clipped to endpoints). For innovation quadrature, supply n_quadrature (default 9), or both innovation_nodes and innovation_weights arrays. Explicit weights are normalized finite nonnegative masses with positive total. Quadrature configuration is static, not a process parameter. All rules accept StateConditioned parameters. Continuous simulation retains the normal law; node simulation uses the selected matrix.

Process-law values (mu, sigma, rho, n_std, start/stop, mixture parameters, JointNormalIIDProcess’s mean and cov, and the values of StateConditioned.by) are floats. An int is accepted and stored as a float, so mu=1 and mu=1.0 declare one law; a Boolean is refused.

A process owns its transition mechanism. Adding a second law under state_transitions is an ambiguous declaration and is rejected.

StateConditioned lets process parameters depend on a categorical state. Use it when one named process changes distribution across observable states without changing the model’s state vocabulary. The conditioning categories and parameter leaves must align with the declared categorical grid. mu and sigma of a CDF-binned NormalIIDProcess, mu, rho and sigma of a CDF-binned TauchenAR1Process, and mu, rho and the mixture parameters of TauchenNormalMixtureAR1Process accept it; several parameters of one process must share the conditioning state and its categories. n_std is a scalar.

An IID process used as a state carries an axis in a regime only when the regime reads its current value. A regime whose state transitions read it only as next_<state> stores no axis for it and integrates the draw in the continuation. See Shock timing.

See Grids and Continuous stochastic processes for worked construction.