Internal Documentation
Documentation for ComposableTuringIDModels's internal interface.
Contents
Index
ComposableTuringIDModels.ARStepComposableTuringIDModels.AbstractBroadcastRuleComposableTuringIDModels.AbstractIDMethodComposableTuringIDModels.AbstractIDSamplingMethodComposableTuringIDModels.ImportedRateComposableTuringIDModels.LDStepComposableTuringIDModels.MAStepComposableTuringIDModels.PriorLikeComposableTuringIDModels.RWStepComposableTuringIDModels.SafeIntValuedComposableTuringIDModels.TVARStepComposableTuringIDModels.TimeVaryingLDStepComposableTuringIDModels._n_strataComposableTuringIDModels._n_timeComposableTuringIDModels._require_finite_for_intComposableTuringIDModels.concrete_observationsComposableTuringIDModels.hsgp_basisComposableTuringIDModels.neg_MGFComposableTuringIDModels.remake_ode_problem
Internal API
ComposableTuringIDModels.AbstractBroadcastRule Type
Abstract supertype for broadcast rules used by BroadcastLatentModel. A rule defines broadcast_n (how long an inner series to generate) and broadcast_rule (how to expand it to length n).
ComposableTuringIDModels.AbstractIDMethod Type
Abstract supertype for inference / generative-modelling methods.
sourceComposableTuringIDModels.AbstractIDSamplingMethod Type
Abstract supertype for sampling-based methods (e.g. NUTS).
sourceComposableTuringIDModels.ImportedRate Type
A resolved ImportedCases: the drawn importation rate, ready to scan.
This is what ImportedCases returns from its pre-scan as_turing_model seam — the prior has been sampled and transformed, so the scan sees a plain deterministic modifier. Its substate is the step counter, so step at (a constant rate stays a scalar).
Fields
rate: the positive importation rate, constant or one value per time.
ComposableTuringIDModels.PriorLike Type
The types accepted in a prior / process slot: a raw Distribution, a vector of Distributions, or an AbstractPriorModel (a latent process used as a prior). Bounding a widened slot to PriorLike keeps the fail-fast role guard — a wrong-role component (an observation or infection model) is rejected at construction — while accepting a bare distribution alongside a process.
ComposableTuringIDModels.SafeIntValued Type
A value-support tag for real-valued count distributions whose eltype must stay integer-typed inside a Turing model even when rand is called.
ComposableTuringIDModels.TVARStep Type
Order-1 AR step for use with accumulate_scan.
The damping coefficient is read per step via at, so the same step serves both a constant coefficient (a scalar ρ, drawn from a Distribution prior) and a time-varying coefficient path (a vector ρ, drawn from a process prior):
Each element of the driving sequence is a (t, ϵ_t) pair; the state is the scalar previous value get_state prepends the seed ρ stays scalar (no per-step allocation), matching the efficiency of a constant AR(1).
ComposableTuringIDModels.TimeVaryingLDStep Type
Time-varying LatentDelay step for use with accumulate_scan.
The time-invariant LDStep holds one reversed delay kernel and applies it at every step. TimeVaryingLDStep instead reads a fresh reversed kernel from the scan input at each step, so the delay can vary with time:
with rev_pmf_t supplied through the driving tuple input = (ϵ, rev_pmf_t). The window slides exactly as in LDStep (drop the oldest entry, append ϵ), so all kernels must share the same length d (a constant convolution window). When every kernel is identical this reduces exactly to LDStep.
ComposableTuringIDModels._n_strata Function
The number of strata implied by a ModelShape: 1 for a length-n path, the first dimension for an (n_strata, n_time) matrix.
ComposableTuringIDModels._n_time Function
The time-axis length implied by a ModelShape: n itself for a length-n path, the second dimension for an (n_strata, n_time) matrix.
ComposableTuringIDModels._require_finite_for_int Function
Guard shared by every entry point that floors a SafePoisson / SafeNegativeBinomial parameter, quantile or summary statistic to an integer. Raises a clear DomainError naming the offending value for a non-finite input, instead of letting the eventual floor/Int conversion fail with an opaque InexactError deep in Distributions.jl or Base.
ComposableTuringIDModels.concrete_observations Function
Narrow a data argument to a concrete element type before conditioning a model on it, when nothing in it is actually missing.
Data simulated from a model's prior keeps a Union{Missing, T} element type even once every entry is concrete. Conditioning on that makes DynamicPPL deepcopy the argument on every evaluation, which Enzyme cannot differentiate in reverse mode. Narrowing avoids both the copy and the failure.
A genuinely partially-missing vector (some entries observed, some missing) is split into a MissingObservations carrier instead: a concrete value vector plus a presence mask, neither of which admits Missing in its type. A fully missing vector, a partially- or fully-missing matrix (the strata data a data-driven Split reads shape from), and a scalar missing, are returned unchanged, and so is an array whose element type is already concrete. A NamedTuple of streams is narrowed field-wise, so each per-stream submodel receives a concrete vector (or a MissingObservations carrier).
as_turing_model(::IDModel, y_t, n) applies this to its y_t automatically. It is exposed for data built elsewhere by simulating from a prior.
Arguments
y: the data argument to narrow — anAbstractArray, aNamedTupleof them, or a scalar (e.g.missing, returned unchanged).
ComposableTuringIDModels.hsgp_basis Function
Build the Hilbert-space GP basis for n evenly spaced inputs.
Returns (Φ, sqrt_λ) where Φ is the sqrt_λ is the length-m vector of m) meaningful across series lengths: n, m and c — none of the sampled parameters — so HilbertSpaceGP calls this once per model construction rather than from inside the @model body; see HilbertSpaceGP for what that leaves when the GP is composed inside another model. Requires n > 1 so the standard deviation (and hence n = 1 would give NaN.
ComposableTuringIDModels.neg_MGF Function
Negative moment generating function of a discrete generation interval w at rate r:
Arguments
r: the exponential growth rate.w: the discrete generation interval weights.
Examples
using ComposableTuringIDModels
ComposableTuringIDModels.neg_MGF(0.1, [0.2, 0.3, 0.5])ComposableTuringIDModels.remake_ode_problem Function
Rebuild an ODEProcess's ODEProblem with freshly sampled state u0 and parameters p.
This is the single seam through which ODEProcess re-instantiates its problem on every sample. The default applies the plain-vector remake(prob; u0, p) that the hand-coded SIRParams / SEIRParams problems expect.
Parameter models whose problem stores parameters differently — e.g. a ModelingToolkit/Catalyst-built problem carrying a structured MTKParameters object plus an initialization system — specialise this on their own type to inject the remake form they need. The Catalyst extension uses the plain-vector build_initializeprob = false path to bypass the init system (and stay reverse-mode differentiable). Dispatching on the parameter model keeps ODEProcess itself backend-agnostic.
Arguments
params: the ODE parameter model (theODEProcess'sparamsfield).prob: the templateODEProblemto rebuild.u0: the sampled initial state vector.p: the sampled parameter vector.