Skip to main content

policy_result.PolicyRun

Population summaries for one history-dependent policy.

Usage

policy_result.PolicyRun(
    info, population, simulation_draws, _trajectories=None, _aggregation=None
)

do(policy=...) returns this type, not a pathmc.simulate.DoResult. A set= query still returns a DoResult. The two cannot be subtracted.

Parameter Attributes

info: PolicySimulationInfo
population: xr.Dataset
simulation_draws: xr.Dataset
_trajectories: xr.Dataset | None = None
_aggregation: _TimeAggregation | None = None

Attributes

Name Description
dataset Unit-mean posterior draws, dims ("time", "chain", "draw").
trajectories Full unit paths. Requires keep_trajectories=True.

dataset

Unit-mean posterior draws, dims ("time", "chain", "draw").

dataset: xr.Dataset


trajectories

Full unit paths. Requires keep_trajectories=True.

trajectories: xr.Dataset

Methods

Name Description
__sub__() Paired difference of two policy results.
aggregate_time() Reduce the time dimension of one policy variable.
by_time() Return per-time posterior draws, shape (n_times, n_samples).
contrast() Paired difference. Innovations already match when the seed matches.
graph() Explain why a policy result has no static intervention DAG.
hdi() Return the posterior highest-density interval [lower, upper].
mean() Return the posterior mean of var under this policy.
plot() Plot the posterior trajectory and HDI, with an optional observed series.
simulation_info() Simulation context, including the baseline states this run used.
simulation_mcse() Per-posterior-draw Monte Carlo standard error of a policy estimand.

__sub__()

Paired difference of two policy results.

Usage

__sub__(other)

aggregate_time()

Reduce the time dimension of one policy variable.

Usage

aggregate_time(var, *, reduction="sum", start=None, end=None)

reduction is "sum", "mean", or "last". start and end are inclusive fitted time labels. The result has no time dimension, so mean() describes that scalar estimand.


by_time()

Return per-time posterior draws, shape (n_times, n_samples).

Usage

by_time(var)

contrast()

Paired difference. Innovations already match when the seed matches.

Usage

contrast(other)

graph()

Explain why a policy result has no static intervention DAG.

Usage

graph()

hdi()

Return the posterior highest-density interval [lower, upper].

Usage

hdi(var, prob=DEFAULT_HDI_PROB)

mean()

Return the posterior mean of var under this policy.

Usage

mean(var)

plot()

Plot the posterior trajectory and HDI, with an optional observed series.

Usage

plot(var, *, vs=None, observed=None, ax=None, prob=DEFAULT_HDI_PROB)

Pass ax to reuse an axes, prob for the interval mass, and observed for a time-aligned overlay. Aggregate results have no time dimension; use hdi() to summarize their uncertainty.


simulation_info()

Simulation context, including the baseline states this run used.

Usage

simulation_info()

simulation_mcse()

Per-posterior-draw Monte Carlo standard error of a policy estimand.

Usage

simulation_mcse(var, *, by=None)

Computed within each posterior draw as the simulation standard deviation divided by sqrt(n_simulations). The chain and draw dimensions are preserved. A time-indexed result keeps time as well; call aggregate_time() first for a cumulative or terminal estimand. by='time' is accepted and does not average draws.