antecedent.inference

Inference-mode configuration for causal.analyze.

 1"""Inference-mode configuration for ``causal.analyze``."""
 2
 3from __future__ import annotations
 4
 5from dataclasses import dataclass
 6from typing import TYPE_CHECKING, Literal
 7
 8if TYPE_CHECKING:
 9    from .prior_bank import ComposedPrior, PriorMapping
10
11
12@dataclass(frozen=True)
13class Frequentist:
14    """Frequentist point estimate + bootstrap SE (default)."""
15
16    kind: Literal["frequentist"] = "frequentist"
17
18
19@dataclass(frozen=True)
20class Bayesian:
21    """Bayesian g-computation (Laplace / conjugate / HMC backends).
22
23    Parameters
24    ----------
25    n_draws:
26        Posterior draw count.
27    prior_scale:
28        Isotropic Gaussian coefficient prior scale when ``prior_from`` is unset.
29        Ignored when ``prior_from`` is provided.
30    prior_from:
31        Posterior artifact bytes from a previous ``result.posterior.artifact``,
32        or a ``ComposedPrior`` from ``compose_external_priors``.
33        Artifact hydrate is deferred until the target design is prepared.
34    mapping:
35        How to map an artifact into the target prior. ``None`` auto-selects:
36        identical coefficient subspace when designs match (sequential Bayes),
37        or ``PriorMapping.effect_functional(...)`` when designs differ and the
38        artifact has an effect quantity. Never silent ``coef_i → coef_i`` across
39        heterogeneous designs. Ignored when ``prior_from`` is a ``ComposedPrior``.
40    backend:
41        Inference backend: ``laplace`` (default), ``conjugate``, or ``hmc``.
42    """
43
44    n_draws: int = 1000
45    prior_scale: float = 10.0
46    prior_from: bytes | ComposedPrior | None = None
47    mapping: PriorMapping | None = None
48    backend: Literal["laplace", "conjugate", "hmc"] = "laplace"
49    kind: Literal["bayesian"] = "bayesian"
50
51
52__all__ = ["Bayesian", "Frequentist"]
@dataclass(frozen=True)
class Bayesian:
20@dataclass(frozen=True)
21class Bayesian:
22    """Bayesian g-computation (Laplace / conjugate / HMC backends).
23
24    Parameters
25    ----------
26    n_draws:
27        Posterior draw count.
28    prior_scale:
29        Isotropic Gaussian coefficient prior scale when ``prior_from`` is unset.
30        Ignored when ``prior_from`` is provided.
31    prior_from:
32        Posterior artifact bytes from a previous ``result.posterior.artifact``,
33        or a ``ComposedPrior`` from ``compose_external_priors``.
34        Artifact hydrate is deferred until the target design is prepared.
35    mapping:
36        How to map an artifact into the target prior. ``None`` auto-selects:
37        identical coefficient subspace when designs match (sequential Bayes),
38        or ``PriorMapping.effect_functional(...)`` when designs differ and the
39        artifact has an effect quantity. Never silent ``coef_i → coef_i`` across
40        heterogeneous designs. Ignored when ``prior_from`` is a ``ComposedPrior``.
41    backend:
42        Inference backend: ``laplace`` (default), ``conjugate``, or ``hmc``.
43    """
44
45    n_draws: int = 1000
46    prior_scale: float = 10.0
47    prior_from: bytes | ComposedPrior | None = None
48    mapping: PriorMapping | None = None
49    backend: Literal["laplace", "conjugate", "hmc"] = "laplace"
50    kind: Literal["bayesian"] = "bayesian"

Bayesian g-computation (Laplace / conjugate / HMC backends).

Parameters

n_draws: Posterior draw count. prior_scale: Isotropic Gaussian coefficient prior scale when prior_from is unset. Ignored when prior_from is provided. prior_from: Posterior artifact bytes from a previous result.posterior.artifact, or a ComposedPrior from compose_external_priors. Artifact hydrate is deferred until the target design is prepared. mapping: How to map an artifact into the target prior. None auto-selects: identical coefficient subspace when designs match (sequential Bayes), or PriorMapping.effect_functional(...) when designs differ and the artifact has an effect quantity. Never silent coef_i → coef_i across heterogeneous designs. Ignored when prior_from is a ComposedPrior. backend: Inference backend: laplace (default), conjugate, or hmc.

Bayesian( n_draws: int = 1000, prior_scale: float = 10.0, prior_from: 'bytes | ComposedPrior | None' = None, mapping: 'PriorMapping | None' = None, backend: "Literal['laplace', 'conjugate', 'hmc']" = 'laplace', kind: "Literal['bayesian']" = 'bayesian')
n_draws: int = 1000
prior_scale: float = 10.0
prior_from: 'bytes | ComposedPrior | None' = None
mapping: 'PriorMapping | None' = None
backend: "Literal['laplace', 'conjugate', 'hmc']" = 'laplace'
kind: "Literal['bayesian']" = 'bayesian'
@dataclass(frozen=True)
class Frequentist:
13@dataclass(frozen=True)
14class Frequentist:
15    """Frequentist point estimate + bootstrap SE (default)."""
16
17    kind: Literal["frequentist"] = "frequentist"

Frequentist point estimate + bootstrap SE (default).

Frequentist(kind: "Literal['frequentist']" = 'frequentist')
kind: "Literal['frequentist']" = 'frequentist'