Skip to content

chc.decision

Stability tier: stable.

One call from a panel of logs to a certified intervention schedule.

Every layer this needs already exists --- chc.graph for which covariates to adjust for, chc.dynamics_id for a control channel that is interventional rather than observational, chc.plan for the constrained solve and its error tube, and chc.plan.certify_safety for what the plan survives under confounding. What did not exist was a way to run them in that order without re-deriving the wiring, so the demo in every README was five imports and forty lines. prescribe is that wiring and nothing more: no new estimator, no new solver, no new guarantee.

The module is chc.decision rather than chc.prescribe for one reason: the headline export is a function named prescribe, and a module of the same name inside the same package is shadowed by it --- after import chc.prescribe, chc.prescribe is the function and chc.prescribe.Lever raises AttributeError. It was the only such collision in the library.

The causal assumption is a required argument. adjustment= takes either a CausalGraph, from which the adjustment set is derived and can come back not_identified, or an explicit sequence of column names, which asserts it. There is no default, because the default would be "adjust for nothing", which is a causal claim this library exists to stop people making by accident.

Two questions, never conflated, following chc.plan.CausalPlan. Whether the effect is identified is about the data and the graph; whether the plan is certified is about the model error and the barrier. DecisionCertificate reports both, and an unidentified effect produces no schedule at all --- Prescription.schedule raises rather than hand back actions computed from a channel nothing in the log pins down.

SCHEMA_VERSION = 3 module-attribute

to_json's schema version. Bumped when a field changes meaning or leaves, not when one is added: 2 writes a number that is not finite as null (ADR 0055); 3 no longer writes the certificate's identification_radius, which repeated channel_error (ADR 0130).

POLICY_SCHEMA_VERSION = 1 module-attribute

PrescribedPolicy.to_json's schema version, which PrescribedPolicy.from_json reads, and no other.

IdentificationStatus = Literal['identified', 'asserted', 'not_identified'] module-attribute

How the set was arrived at. asserted means a caller named it and nothing here checked it.

TubeRate = Literal['global', 'local'] module-attribute

Where the error tube's rate bounds the field's slope in the state: at every state, the levers anywhere in their box, or at the plan's start alone.

TubeMode = Literal['exact', 'bound'] module-attribute

What each radius of the error tube is. Each holds, with probability 0.95, the plant's own noise (ADR 0080) and the fitted field's error, the channel's and the drift's, beside it: a standard error whose spread the log estimates, read at the state each of the plan's steps starts from and at its studentised quantile as an error independent of the noise (ADR 0104). exact: on a field affine in the state, both carried through RK4's step matrix of the field's slope at each planned action, so the radius is the exact 0.95 quantile of the two at that step under the fitted field. bound: both carried by a bound on the norm of the slope, so the radius holds at least 0.95, exactly at the first step.

TubeActions = Literal['box', 'plan'] module-attribute

Which actions the error tube's field part holds for. box: any action of the levers' box, each step's error read at the box's worst vertex and the steps' carried by their gains' norms (ADR 0133). plan: the plan's own actions, the fit's error carried through the plan's rollout as one vector, so the steps' errors cancel where the actions change sign (ADR 0138). Experimental.

TimeZero = Literal['calendar', 'unit'] module-attribute

Where Prescription.evaluate's windows start: on one calendar for every unit, or cut back from each unit's own latest period.

Estimability = Literal['estimable', 'held_to_log', 'not_estimable'] module-attribute

Whether the log determines the plan's predicted path (ADR 0054). estimable: the log moved every direction of the channel. held_to_log: it left some unmoved, and the plan keeps to what the log did along them, so every fit the log cannot tell from the fitted one predicts the same path. not_estimable: some such fit predicts another path from DecisionCertificate.first_loaded_step on, or no plan could keep to the log and none was made.

GammaStarStatus = Literal['finite', 'every_level', 'no_level'] module-attribute

What DecisionCertificate.gamma_star reads. finite: the level past which some step's barrier no admissible action keeps. every_level: inf, every step's barrier is kept at every level: under the absolute radius, where the drift alone keeps a step or no confounding widens the radius; under the relative one, the radius then the whole gap's share of the fitted channel, against every effect within that much of the estimate, not against any effect at all. no_level: nan, some step's barrier no admissible action keeps, not even at gamma = 1, which under the absolute radius is the channel's sampling error alone.

DitherStatus = Literal['tested', 'void'] module-attribute

What DitherCheck read: "tested", the contrast and its p-value; "void", no test, since the two fits are one up to rounding.

DecisionError

Bases: ValueError

A decision could not be set up: a lever, a target, a constraint or an adjustment is wrong.

Subclasses ValueError so it stays catchable the way it always was, and exists so a caller wrapping prescribe can tell its own mis-specification apart from a ValueError thrown out of jax, numpy or the solver. Every message names the offending column or bound.

Columns that are simply absent still raise KeyError, matching Panel lookup: asking for a name that is not there is a lookup failure, not a bad decision.

NotIdentifiedError

Bases: DecisionError

The effect is not identified by adjustment, so there is no schedule to hand back.

Its own type because it is the one failure this library exists to produce. A caller may want to fall back to chc.research.sensitivity's partial-identification path on exactly this and on nothing else; catching it by message would be catching it by accident.

LeverRelation dataclass

A combination of the levers the log kept at one level, sum_j weights[j] u_j = level, which the plan keeps at every step. weights has one entry per lever and unit length.

Lever dataclass

One actionable column and the box it may move in.

unit_cost is the quadratic price of using it, and defaults to free: with a box constraint a free lever is still bounded, so the default is safe rather than merely convenient.

cap_per_step bounds how far the lever may move between consecutive planned steps. None lets it jump anywhere in its box from one step to the next, which is a schedule a media plan, a rota or a price list often cannot execute. The move from the level already in force to the first planned step is not capped, since the planner is not told what that level is.

Target dataclass

The column to steer and where to steer it.

value is one level for the whole plan, or a schedule with one level per step: value[k] is the level for the state after k + 1 actions, so a schedule has horizon entries. A schedule is how a set point that moves inside the horizon reaches the plan --- a comfort band that tightens at eight is steered for before eight, not re-planned for after it.

Constraint dataclass

A state that must stay inside a range --- what the safety certificate is priced against.

Each finite bound is a barrier of its own, x - lo or hi - x, and a step is certified where the condition of every bound holds, the far one's as well as the near one's: the state approaches neither faster than the class-K gain times its distance to it.

state may be the target column: the steered state is then bounded as well as steered, which is how a comfort band around a set point is stated. A target value outside its own bound is allowed and means "as close as the bound permits"; holding the bound is what keeps the plan from crossing it on the way.

Driver dataclass

An exogenous column that pushes the state, and its forecast over the plan.

forecast[k] is the level at t = k * dt, so a forecast has horizon + 1 entries: one at the start of every step and one at the end of the last. Between two entries the driver moves linearly, which is how the fit reads it off the log (chc.dynamics.DrivenDynamics). Nothing the plan does moves a driver --- weather, a published demand forecast; a column the levers can move is a state, not a driver.

InterventionSchedule dataclass

What to set each lever to, step by step.

windows(*, tol=1e-06)

First and last step at which each lever is active, or None if it never is.

Derived rather than stored: a start/stop pair that can disagree with the magnitudes it summarises is a worse footgun than computing it twice.

PrescribedPolicy dataclass

The decision as a rule to run, step by step, in the state each step reaches.

A lever the plan moves takes the schedule's level at the step. A lever the log set from the state alone (DecisionCertificate.rule_levers) takes the log's rule at the state it is given, as the plan's field and its price read it (ADR 0054), so its column of schedule is nan. A lever the plan holds to the log, or one the selection left out, keeps the level the schedule holds it at. Along the path the plan predicts, the actions are Prescription.schedule's. Experimental.

horizon property

How many steps the policy runs.

ruled property

The levers set from the state on the log's rule, in the order of levers.

actions_at(step, state)

Each lever's level at step in state, in the order of levers.

state is the states' values in the order of states, or a mapping that names each of them; a name it holds besides is not read.

Raises:

Type Description
ValueError

on a step that is not an integer from 0 to horizon - 1, or a state that does not give each of states a finite value.

to_json()

The policy as plain JSON-safe values, which from_json reads back to the bit.

No number is infinite or nan (ADR 0055). A ruled lever's column of schedule is None, as its rule sets it; rule names those levers and holds the rule, an infinite bound of its as None: lo's is -inf, hi's inf. precision names the floats the rule reads the state in, None where there is no rule.

from_json(record) classmethod

The policy to_json wrote.

Raises:

Type Description
ValueError

on a record of another schema version, or one that does not run: names that are not distinct, a schedule that is not a finite number for each lever at each step, a ruled lever's None excepted, a rule that does not fit the levers and the states, or a rule read in a precision JAX does not now run in.

DecisionCertificate dataclass

What is known about the decision, on the two axes that must not be merged.

Identification is about the data and the graph; certification is about model error and the barrier. A plan can be fully certified against a channel nothing identifies --- that is a trustworthy tube around a meaningless action --- so both are reported and neither is derived from the other.

stationarity_status property

How stationarity reads against its tolerance (chc.plan.DiagnosticStatus); None where no plan was solved.

violation_status property

How constraint_violation reads against its tolerance; None where no plan was solved.

trustworthy_steps property

The prefix that survives both axes --- the number an operator can act on.

Zero whenever the effect is not identified, whatever the tube says, and never longer than the shorter of the two certified prefixes, nor past the first step a fit the log cannot tell apart predicts differently. The two None values mean different things. certified_horizon is None means the tube was not evaluated, so nothing bounds the trajectory's error and it contributes zero rather than infinity --- a barrier cleared by an unbounded trajectory proves nothing. A tube read against an infinite tolerance (certificate_status no_tolerance) contributes zero as well: it holds every finite radius at every step, and bounds nothing. barrier_certified_steps is None means no state was bounded, so there is no safety prefix to respect and the tube alone decides.

Where the channel's residual persists within units (noise_persistence_p at most 0.05) the noise the tube reads may not be the plant's, and a tube warning says so; the prefix still counts the tube's steps (ADR 0105).

gamma_star_status property

What gamma_star reads (GammaStarStatus); None where no bound was audited.

SelectionStep dataclass

One step of the greedy lever selection: the lever it added, and what the plan cost with it.

regret_bound is chc.plan.plan_regret_bound on that step's plan, priced against every lever's box, the levers not yet selected included. So it bounds how far below task_cost any plan the boxes allow can go: what the levers left out at this step could still buy, plus what the solve left on the table. inf when the objective was not convex over the boxes, as in DecisionCertificate.regret_bound; regret_status says which.

LeverSelection dataclass

Which levers prescribe kept under max_levers, in the order it added them.

What a step bought is the drop in planned cost from the step before it; idle_cost is the planned cost with every lever held at zero, which is what the first step is measured against.

DitherCheck dataclass

The channel the plan was made on against the channel the logged draw instruments, priced in the plan's own regret. Experimental.

A logger that sets the levers from the state, a draw and a column the graph leaves out leaves an adjusted channel that is biased by that column's push, and a log of the states and the levers alone has the law of a loop without it where the column is drawn afresh and Gaussian: no test that reads only those can see it (validation/confounded_log_equivalence.mac). The draw, logged, can: it moves the levers apart from anything the plant reads, so the channel it instruments, conditioned on the states alone, holds whatever the graph says, and its distance from the adjusted one is a Durbin-Wu-Hausman contrast (Hausman, Econometrica 1978; as a test of unconfoundedness against an instrument, Donald, Hsu and Lieli, JBES 2014). prescribe reads it by chc.misspecification.misspecification_cost, with the plan's fit as the reference and the instrumented one as the alternative: a Hausman test in the plan's regret metric, its power where the plan's cost is.

A rejection says that the graph or the model's class is wrong, not which: where the class misses the plant, the two fits estimate different projections of it. contrast.cost says what it would cost the plan, to second order, were the instrumented fit's model the plant's, and a stop rule reads the two together: reject at its level, and a cost above what the caller tolerates. On a scalar plant x' = a x + b u + c w + sg e whose logger sets u = d w + s eta, w the omitted column and eta the logged draw, both drawn afresh, the test's noncentrality grows by c^2 s^2 / (sg^2 (d^2 + s^2)) a transition (validation/dither_hausman.mac): a small draw pays for the instrument's variance, and a draw of a tenth of the logger's spread needs about fifty times the transitions of one as large.

The two fits differ in what identifies the channel and in nothing else: the instrumented fit's moment reads the states alone, and its drift holds the adjustment set's push, as the plan's fit's does. A covariate that persists leans on the state, since its past pushed it, and a drift on the states alone reads that lean into its slope: on the plant above at a = 0.9, b = 0.5, c = 0.8, d = s = sg = 1, with w AR(0.9) and held by the graph, 0.154 of w's push over five transitions a unit (validation/dither_persistence.mac). Up to 1.3.1 the instrumented drift held nothing, and there the contrast rejected the right graph on 57 of 200 logs of 100 units at 5 %; holding the push, on 1. Under "rk4" that drift also reached the channel, through RK4's growth factor (ADR 0159). On causaldyn-bench's persistent-confounder world under "rk4", 400 units over 12 periods, the right graph's contrast rejects at 5 % 0.035, 0.010, 0.040 and 0.030 of 200 panels at a persistence of 0, 0.5, 0.8 and 0.95 (0.000, 0.000, 0.085 and 0.265 up to 1.3.1): at most the level, and below it beyond the Monte Carlo error at 0.5, where it rejects 0.09 at 10 % and 0.18 at 20 %.

The check's power sits below that closed form's one-degree power, for two measured reasons (scripts/bench_dither_power.py). At a = 0.9, b = 0.5, d = s = sg = 1, 100 units over 5 transitions and a 5-step plan, the closed form at the fixed alternative rejects at 5 % 0.64 of the logs at c = 0.15 and 0.975 at c = 0.27. On 400 logs at each, the channel's contrast kept the closed form's mean and standard error within 3 %, and the channel's level alone, studentised by that standard error, rejected 0.60 and 0.99 (Monte Carlo standard errors 0.025 and 0.005). First, the check prices the difference in the plan's regret over four parameters, the channel's two and the drift's two, and only the level carries the bias: with the difference's covariance over the logs in place of a read, it rejected 0.54 and 0.905. Second, it reads that covariance off its one log, as the largest of three reads (two ways, the units alone, the 5 periods alone at their CR1 factor), and reads tr(W S) 1.4 to 1.6 times high on average: it rejected 0.39 and 0.875, and at c = 0 it rejected 0.025 where the covariance over the logs rejected 0.045. The second cost is the price of the check's margin on its size.

"void": the logger read nothing but the states and its draw, and the plan's fit conditions on the states alone: the levers are, to rounding, the nuisances' polynomial of the states plus a linear map of the draw. The two fits then draw the channel from one variation, the draw's, and there is nothing to falsify: the plan's fit is the design's own. Their difference's tr(W S) is zero but for the nuisances' own error, which the cross-fitted fits keep apart: on 500 transitions of a scalar plant it read 0.001 to 0.013 of the instrumented fit's, where a contrast made without cross-fitting would read rounding, and test it. contrast is None there, and share is still read.

StartState dataclass

The state the plan starts from, or would have, and where it came from.

source is "given" for a caller's x0 and "panel" for the panel's own: the mean over its units of each unit's last logged state. A mean over units that sit far apart is a start no unit is at, so the panel's start keeps how many units it averages, the periods their last states were logged at, and each state's spread over them.

RunProvenance dataclass

What the run used, beside the panel's Provenance (ADR 0063).

The panel's record is made when the panel is built, and a run need not match it: a panel built under JAX's x64 and planned on with it off fits on float32 transitions while its record reads True. So each field here is read where the run used it: x64 as prescribe ran; the device and the fit's dtype off the transitions the fit ran on; the solve's dtype, why it stopped and after how many steps off the plan the planner returned; each setting as the fit and the planner were given it; and each version from the installed distribution's metadata.

to_json()

A plain dict, ready for json.dumps(..., allow_nan=False): the versions an object keyed by distribution, and an infinite tolerance null.

Prescription dataclass

The decision, the evidence for it, and what it took to get there.

schedule property

The actions to take.

Raises:

Type Description
ValueError

if the effect is not identified. Returning a schedule here is the exact failure this library exists to prevent: the numbers would look like every other schedule and mean nothing. Read DecisionCertificate.adjustment for why, and chc.research.sensitivity for what to do about it.

policy()

The decision as a rule to run step by step in the states it reaches: the schedule for the levers the plan moves, the log's rule of the state for those the log set from it.

Raises:

Type Description
NotIdentifiedError

if the effect is not identified, as schedule does.

ValueError

on a prescription prescribe did not build, which does not record its states or the rule its levers keep to.

budget_prices(tolerance=None)

What each budget is worth to the plan: one price per period it holds in the plan.

A period's price is how much the planned cost falls per unit more it may spend, in the cost's units per unit of spend; zero where the period has room. Read as chc.plan.CausalPlan.shadow_prices reads every row, whose tolerance this is. A period the horizon cuts short may spend its share of the budget's amount, so a unit more of amount is worth its price times that share, which report prints.

Raises:

Type Description
NotIdentifiedError

if the effect is not identified, so no plan was made.

ValueError

if the plan was held under the constraints' barrier (hold_constraints), whose rows' prices are not built.

evaluate(panel, *, logger=None, smoothing=None, model_error=1.0, min_effective=100.0, time_zero='calendar', n_resamples=200, seed=0, max_refused=0.05, interval='bootstrap')

The schedule's expected cost over its horizon, estimated from panel before it is deployed, beside the cost of the policy that logged the panel: chc.evaluation.evaluate_plan by "pdis", whose keywords the first four are, with its intervals read from a bootstrap over the units.

What it is handed: the episodes are windows of H + 1 consecutive periods of a unit, over the plan's states and the levers; the schedule is the plan's actions, open loop; the cost is the plan's own, less its terminal term; the plant is the plan's model over one step, linearised at the episodes' mean state and action, with the covariance of its one-step residuals on them as the noise. panel may be the one the plan was fitted on, and the plan was chosen on it, so a value read off it can be optimistic; a later one is not.

Where the plan was made on groups (prescribe(clusters=)), panel is grouped by the same column first, as prescribe grouped the panel it fitted: a group's row in a period is the mean of its units' rows logged then, so panel must hold that column. The windows, the logger, the plant and the bootstrap's draws are then the groups', and min_effective counts the groups' windows. The value is the grouped plan's own cost, the objective it was chosen on: of each group's mean state when every unit of the group follows the schedule. It is not the units' mean cost under the plan, which exceeds it by the target's weight times half the spread of the units' states about their group's mean, a variance, summed over the steps: no grouping of the panel reads that. On panels of 150 groups of four units over 24 periods, each unit's state moved 0.5 by its own lever and 0.4 by its group-mates' mean, the default min_effective refused each of 10 panels, its certifiable horizon at most 3 of 4 steps. At 30 it refused 6 of 200, and on the rest the interval at model_error=0 covered the group-mean cost on 0.861 (MC SE 0.025), the value 2.5 MC SEs under it by the normalised weights' bias, which normalisation_bias reports (ADR 0155). Up to 1.1.0 the units were read one by one, so the weights read a unit's own lever against its group-mates' logged ones, and that interval covered the group-mean cost on 1 of 40 panels and the units' mean cost on none.

A lever the log never moved, which the plan holds at the level the log kept it at (DecisionCertificate.unmoved_levers), has no spread for a weight to read: it leaves the windows' actions, the logger and the smoothing, and its price at that level over the horizon is added to the plan's value and to the logger's. A panel that moves it, or keeps it at another level, is refused naming it. So is a logger, given or fitted, that leaves a lever, or a combination of the levers, less spread given the state than the square root of the working precision of their size: the weights divide by its density.

A window starts at its time zero, where a target trial starts each unit's follow-up: when the unit is eligible and is assigned a strategy (Hernán and Robins, Causal Inference: What If, section 22.4). Under "calendar", the default, the time zeros are the panel's periods H, 2H, ... before its last, the same for every unit, and a unit gives every window it was observed throughout. Under "unit" each unit's windows are cut back from its own latest period, a gap ending a run: where a unit's record ends then sets where each of its windows starts, so when a unit leaves the panel because of what happened to it, its windows are chosen by their own outcomes, and the value read off them is biased.

One unit's windows follow each other, dependent through its state, so the intervals come from n_resamples draws of the units with replacement, from seed, every window of a drawn unit kept. Each draw runs the evaluation again: the plant is linearised again, the logger fitted again unless it is given, the smoothing chosen again unless it is given, and the certificate and the values computed again. An interval is its estimate plus or minus 1.96 standard deviations of its draws, widened by the model's correction as evaluate_plan widens its own; a draw the certificate refuses is left out and counted (PlanEvaluation.bootstrap). With few units the draws are few distinct panels and the intervals too narrow. The estimate of a quadratic cost under importance weights is skewed to the right, and the spread its draws read rises and falls with it, so the misses fall where it reads low: on panels of 60 units of five windows, no draw refused, the plan's interval covered 0.925 on a two-state market (800 panels) and 0.902 on one state (757 panels), the difference's 0.945 and 0.916. On 30 units of ten windows they covered 0.917 and 0.895 (2000 panels, Monte Carlo SE 0.006 to 0.007), the difference's 0.923 and 0.924, and the draws' spread read 0.89 to 0.93 of the estimate's. A BCa interval over units, a log or square-root transform of the cost, Hall's skewness correction, the logged policy's fitted influence, Student's t with the units less one (0.928 and 0.908), CR2 with it, the bootstrap-t, and the wild cluster bootstrap restricted to the value tested, with Rademacher's or Webb's weights, each left the plan's interval short of 0.95 on both plants.

interval="jackknife" reads both intervals from the jackknife over the units in place of the draws: each unit is left out in turn and the evaluation run again on the rest, as on a draw, each leave-out certified against min_effective scaled to the windows it keeps; a leave-out it refuses refuses the evaluation. The spread is CV3, the leave-outs' about the estimate, and each interval is Student's t with the units less one times it, widened by the model's correction (MacKinnon, Nielsen and Webb, J. Econometrics 232, 2023): PlanEvaluation.degrees_of_freedom is the units less one, bootstrap is None, and n_resamples, seed and max_refused are not read. It runs one evaluation a unit. On the 30-unit panels above it covered 0.938 and 0.919, the difference's 0.944 and 0.944, 1.08 to 1.13 times as wide as the bootstrap's; on 750 panels of 60 units, where the bootstrap covered 0.932 and 0.900, the difference's 0.936 and 0.933, it covered 0.943 and 0.924, the difference's 0.956 and 0.948; and on 1000 panels of 60 units of ten windows of a loop that keeps 98 % of its slower mode a step, 0.923 where the bootstrap covered 0.913. It narrows the shortfall, the misses still where the estimate reads low, and does not close it (ADR 0160).

Near the certificate's edge a draw whose units start wider or weigh heavier than the panel's is refused, so the draws read are the narrow side of the spread: the intervals are then conditional on certification, and reading says so, "conditional". Where more than max_refused of the draws are refused it is "inconclusive", logged as a warning: the intervals are too narrow to read. accepted and accepted_share count the draws read.

Windows of one unit leave nothing to resample, and they follow each other through its state and its noise. Each window's influence on the estimate, the delta method's, is read across the windows' time zeros by the equal-weighted cosine estimate, nu cosines of E windows, nu the most whole ones at or below 0.4 E^(2/3), and each interval is Student's t(nu) on it (Lazarus, Lewis, Stock and Watson 2018), widened by the model's correction; PlanEvaluation.degrees_of_freedom is nu and bootstrap is None. A window's time zero takes its place on the grid of H periods, so a gap leaves its places empty. The logger and the smoothing are held at the estimate's. Measured on one simulated unit (a loop keeping 0.5 or 0.8 of its state a step, its noise AR(0), AR(0.5) or AR(0.9), horizons 4 and 10, 25 to 1600 windows, 1000 logs a cell), the 95 % intervals covered 0.87 to 0.99, where the windows taken as independent covered 0.75 to 0.99; where the loop keeps 0.8 and the noise is AR(0.9), 0.82 to 0.95 against 0.64 to 0.85. They were 1.04 to 2.3 times as wide, 1.66 at 25 windows of fresh noise (ADR 0083). The difference's interval, PlanEvaluation.versus_logger, covered less, for the same skew: 0.88 at 100 windows of four steps of fresh noise where the plan's covered 0.97, and 0.74 to 0.79 at ten steps where the loop keeps 0.8 and the noise is AR(0.9).

PlanEvaluation.versus_logger holds the plan's value less the logged policy's, on the same windows, its interval read off the difference within each draw. The policy in place can cost less than the plan; the difference is what switching to the plan would change.

Scope: what chc.evaluation states, and two things more. The logs' actions must depend on the state and a randomisation of their own alone, so a plan whose levers were logged on a column outside its state is refused: the weights need the logger's propensity given that column, and no policy of the state is that. The graph says what the levers were logged on, their parents; an asserted adjustment is taken to name it. A covariate adjusted for only because it moves the target is no reason to refuse. And a window is read only when its unit was observed to its end. A unit that leaves the panel because of what happened to it after a window's time zero takes that window with it, and the windows left are not those an unselected panel would hold; weighting them by the chance of staying, which would correct that, is not built. Leaving on what happened before a time zero moves only the law the windows start from, which the value is read at.

What the graph cannot say, the panel is asked: whether the levers read a column besides the state, or the state's past (PlanEvaluation.logger_check, as Prescription.logger_check on the panel the plan was fitted on). On enough rows it also flags levers that read the state through more than a quadratic, such as a logger that switches at a threshold; the logger fitted here is affine, so that premise fails too. A rejection is logged at INFO and changes nothing else. Experimental.

Raises:

Type Description
NotIdentifiedError

if the effect is not identified, so there is no plan.

DecisionError

on a time_zero other than "calendar" and "unit"; fewer than two resamples; a max_refused outside [0, 1); an interval other than "bootstrap" and "jackknife"; a plan made against driver forecasts, whose plant changes with the step; a plan with a lever that follows its logged rule of the state, which no open-loop schedule carries; a plan whose levers were logged on a column outside its state, or whose record does not say; a panel with fewer than two windows; a panel that moves a lever the plan holds, or keeps it at another level; or a logger that leaves a lever no spread given the state.

InfeasibleEvaluation

when the evaluation's certificate refuses, on the panel or on every draw but one, or under the jackknife on the panel without one of its units.

PanelError

when a state's or a lever's column of panel does not hold real numbers, as prescribe refuses it.

reach()

Per lever, how far it can move the target's rate across its own box, where the plan starts; None where the log does not identify the lever's own effect.

The fitted control channel on the target's row, read at the state the plan starts from, or would have where the effect is not identified, times the width of the lever's box. A channel affine in the state has no one value: up to 0.12 this read its constant term, its value at x = 0, which a log of rooms at 20 °C never comes near, and a fit whose channel was negative everywhere in the log read positive there. A large coefficient on a lever that may barely move is not a large lever, which is why the range is in the number and not only in the footnote.

A lever the log set from the state, or moved only together with others, reads None. Its entry of the channel there leans on a direction the log never moved (chc.dynamics_id.CausalDynamicsFit.unmoved), where the fit holds the channel by a convention, not an estimate: on a log whose second lever was always twice the first, up to 0.14 this read 2.05 and 1.02, a split of their joint effect that any other split fits as well.

Read from the same fit that produced the plan, deliberately. Ranking by a second estimator --- local projections, say --- invites an ordering that contradicts the schedule printed beside it, and two disagreeing orderings on one page is worse than one.

Raises:

Type Description
ValueError

on a prescription that records no start, one built other than by prescribe without a plan; or on one whose fit left a direction unmoved and that does not record which levers the log identifies alone, one built other than by prescribe.

explain()

The levers ranked by reach, widest first, as text, and those whose own effect the log does not identify, by name.

report()

A Markdown summary: the decision, both certificate axes, and the provenance.

Text only, from string templates. No plotting dependency, so the output is deterministic and can be asserted on in a test rather than eyeballed.

to_json()

The schedule, both certificate axes and the provenance, as plain JSON-safe values, and what the decision was made from, which from_json replays.

No number is infinite or nan: one that is not finite is None (ADR 0055). Where None has more than one reading, a status beside it says which: regret_status refused for an infinite regret_bound, a selection step's own regret_status for its bound, gamma_star_status for gamma_star (GammaStarStatus), and stationarity_status and violation_status for stationarity and constraint_violation (chc.plan.DiagnosticStatus).

Since 0.24.0 the record also holds, under keys of their own, so that no key's meaning moves (ADR 0145):

  • the certificate's planned_cost_bias, the planned cost, its bias's three terms, the bias, the largest over it and the reads of its covariance (bias_upper), its direction and the corrected cost, or None, and planned_cost_bias_reason, why it is None;
  • logger_check, the logger check's verdict (LoggerCheck): its statistic, p-value, each pair's partial correlation and the one it could detect, a nan correlation or an infinite detectable one None; None where it was not run;
  • dither_check, the dither check's (DitherCheck), None where none was asked;
  • inputs, every argument of prescribe that moves the result, the panel's data_sha256 and its declared cluster (panel_cluster) as handed in, the same digest over its rows sorted by unit and period (panel_sorted_sha256), and the graph with each edge's provenance (EdgeProvenance); a known model is recorded by a digest of its arrays and structure alone. In inputs an infinite number is the text "inf" or "-inf", so that it stays apart from None, which there means not given. None on a prescription prescribe did not build.

from_json(record, panel, *, model=None) classmethod

The decision record holds, made again: prescribe on panel with the record's inputs, checked to give the record back. Experimental.

panel is the panel the decision was made from: its rows in any order, which inputs.panel_sorted_sha256 digests sorted by unit and period, and its declared cluster, which moves the channel's error and is not part of the digest, must be the ones the record names. model is the known model the decision was made with, where it was made with one: the record holds its digest alone, and refuses a model of another. The replay reproduces the decision, every number to the bit, on the release and the precision that wrote it (ADR 0145). The digests of the rows in the order they were handed in, inputs.panel_sha256 and provenance.data_sha256, are not compared: the replay returned holds this panel's.

The rule: a record replays on the release of the library that wrote it, under the same jax_enable_x64, with schema_version 3 and inputs, which no record before 1.0 holds: 0.24.0 wrote version 2, and 0.23.0 and before no inputs. Its other versions (run.versions: jax, jaxlib, numpy, scipy), its backend and its device kind (run.backend, run.device_kind) name the machine, not the decision: they are not compared, and the replay returned holds this machine's. Where one differs and moves a number, the check below names the number and the versions that differ.

Raises:

Type Description
DecisionError

naming the field, on a record of another schema_version, or one that is not JSON's integer, without inputs or a field the replay needs, written by another release of the library (run.versions) or under another precision (run.x64), on a panel of another seed or frequency (provenance.seed, provenance.frequency), of other data (inputs.panel_sorted_sha256) or of another declared cluster (inputs.panel_cluster), without the known model the record names, or with one of another digest or where the record names none (inputs.known); on an input that does not read as prescribe's argument, or that it refuses, naming inputs.<key> where the refusal names the argument or a column the argument names, and inputs where it names neither, with the refusal's own words; and where the replay does not give the record back, naming the first field that differs and the versions that differ from the record's.

prescribe(panel, *, levers, target, horizon, adjustment, constraints=(), hold_constraints=False, budgets=(), max_levers=None, known=None, dt=1.0, gamma=1.0, radius='auto', tolerance=None, x0=None, folds=2, seed=0, integrator=None, drivers=(), neighbours=None, clusters=None, nuisance_knots='auto', tube_actions='box', dither=None, planned_cost_bias=False, barrier_drift_error=False, inner='diagonal')

Fit the causal control channel from panel and plan a certified schedule on it.

Parameters:

Name Type Description Default
panel Panel

long-format logs. Consecutive periods within a unit become the (x, u, x_next) transitions the channel is fitted on; gaps are dropped rather than interpolated, so an unbalanced panel is fine and a silently invented row is not. The channel's standard error, and with it the tube's budget, sums the scores within each group of the panel's declared cluster, or of its unit where it declares none, before squaring them (clusters in fit_causal_residual): the transitions of one unit share whatever persistent noise the model leaves out. It sums them within each period as well, and the error is the largest of the groups' and the periods' sums together and of each alone (ADR 0061): a shock every unit shares in a period, met by levers the units move together, makes the transitions of one period move together across units, and summed by unit alone the error read 0.29 to 0.58 of the estimate's spread. A panel whose transitions all fall in one group, one unit's or one declared cluster's, has no second group: it sums its transitions' scores within each period and reads the sums' dependence across the periods by cosines of them (periods in fit_causal_residual, ADR 0075), and where they all start in one period as well, takes them as independent. One whose transitions all start in one period sums within groups alone. The certificate says which it was (DecisionCertificate.error_clustered_by, error_periods, error_cosines).

required
levers, target, constraints

the decision, in the domain's own names. States are the target column followed by each other constrained column, in that order. A constraint may name the target column itself: it then bounds the steered state, which gets the barrier and gamma_star like any other constrained column, and adds no state. A lever's cap_per_step is held by every iterate of the solve; the regret bound stays priced against the box alone, so with a rate limit it is conservative rather than tight.

required
hold_constraints bool

hold constraints inside the solve, as the barrier condition chc.plan.certify_safety audits at gamma (chc.plan.BarrierConstraint), rather than only price the plan against them. Off by default, so no existing schedule moves; the certificate reads the same audit either way, and it is still the verdict -- a solve stopped by its budget can come back short of the condition. Each bound's condition is held on its own, as the audit reads it. The regret bound then includes what holding cost, since it is still priced against the box alone.

False
budgets Sequence[PeriodBudget]

what the plan may spend (chc.mpc.PeriodBudget): at most amount in each period steps from the plan's first, a step spending weights @ u, with each lever's spend per unit in the levers' order. A period the horizon cuts short gets its share of amount, so a budget for the whole horizon has period=horizon; the rows are chc.mpc.RecedingHorizon's at its first step, with nothing spent, and every iterate of the solve holds them. Prescription.budget_prices says what each period's budget is worth to the plan; the regret bound stays priced against the box alone, as with a rate limit.

()
max_levers int | None

plan with at most this many levers, chosen by greedy forward selection with chc.plan.causal_plan as its inner loop. Starting from no lever, each step plans once per lever not yet chosen, with that lever added, and keeps the cheapest plan --- under hold_constraints, the one the audit clears over the longest prefix first. Greedy is not exhaustive and can miss the best set; docs/adr/0004-greedy-lever-selection.md shows where. An unselected lever is held at zero at every step: the level at which the fitted control-affine channel credits it with no effect and its unit_cost charges nothing, and the level InterventionSchedule.windows reads as inactive. So every lever's box must contain zero. A lever the log never moved is no candidate, and stays on what the log did (below). The steps, each with its planned cost and regret bound, are Prescription.selection; the certificate's regret bound stays priced against every lever's box, so it includes what leaving levers out cost. None plans with every lever, as before; a value at or above the number of levers selects them all and returns that same plan.

None
adjustment CausalGraph | Sequence[str]

a CausalGraph to derive the adjustment set from, or a sequence of column names to assert it. Required, and deliberately so --- omitting it would default to adjusting for nothing, which is a causal claim, not an absence of one. A graph is read over the period a transition spans: the levers at its start, the states, the target and each constrained column, a period on, and the states at its start conditioned on, as the fit conditions on them whatever else it adjusts for. Over the columns, an edge into a state moves that state a period on, and every other edge acts within the period, a latent's too: so c -> u is a logger that reads the state c, a path the state at the start blocks. The set is derived for the levers' effect on every state together, since one set reads the channel into all of them: where no set does, the effect is not_identified, and the reason names the states no set identifies it on alone. A logger that reads a state its lever moves, y -> u beside u -> y, is a cycle over the columns, which CausalGraph refuses; draw it with unrolled over lags=1: what the logger reads at lag 0, ("y", "u", 0), each move at lag 1, ("u", "y", 1), and each state's own at lag 1, ("y", "y", 1). The transition then runs from its slice t-1 to t, and only columns at t-1 are adjusted for; a latent that persists across periods is drawn so too, at every lag it acts. An empty set a graph derives, for a randomised lever or one set by the states alone, is fitted as identified, with its errors and its tube; an asserted empty set is fitted as the observational regression, with neither.

required
known Dynamics | None

physics kept fixed and not estimated. None means nothing is known and the whole vector field is the fitted residual. The fit reads it at each transition's start, its period's steps from the panel's first period times dt; the plan reads it from t = 0, so a known that reads the time is planned on the clock of the panel's first period, not of the start.

None
dt float

the time step one panel period represents.

1.0
gamma float

the marginal sensitivity model's level the barrier is priced at, passed to chc.plan.certify_safety with the radius below, the log's mean action as centre and each lever's largest distance from it its box allows as u_max, so gamma_star and the barrier's certified steps read the same in any units of the state or of each lever and wherever a lever's zero is (ADR 0085, ADR 0091, ADR 0132), and the levers' box, which may be asymmetric. It prices the plan, and changes it only under hold_constraints.

1.0
radius Literal['auto', 'absolute', 'relative']

what the barrier's radius on the channel is; the certificate's radius_model and RunProvenance.radius read which one the audit used (ADR 0125). "absolute": the fit's own sensitivity model, chc.plan.ChannelSensitivity.from_fit at 0.95, a bound on the channel's error read at each planned step's predicted state, its sampling error at gamma = 1 and its bias besides at a hidden confounder that moves the levers' density by a factor within [1/gamma, gamma], finite at every finite gamma. The held solve and the audit read the same one. It needs a least-squares channel on the Euler rates (ADR 0111): an "euler" fit by adjustment, not an instrument's, whose log moves every direction of the channel; asked of a fit that gives none, an "rk4" fit's among them, it raises. "auto", the default: the absolute radius where the fit gives one, and the relative one otherwise, an INFO record naming the fit's refusal (chc_event="radius"). "relative": a share of the fitted channel's size at the plan's start, (gamma-1)/(gamma+1) of it, so at every level the set stays within the channel's own size of the estimate, and gamma and gamma_star are a margin on the estimate, not a level of confounding; gamma = 1 is then a radius of zero, the ordinary barrier. Up to 0.19 the radius was always the relative one.

'auto'
tolerance float | None

the trajectory error above which the plan stops being certified. Omitting it switches the tube off rather than setting it to infinity: this library cannot know how much error a caller accepts, and a certificate with an infinite tolerance passes over the whole horizon while proving nothing. The tube carries two errors over the plan's steps, by the integrator's map, at the rate DecisionCertificate.tube_rate names: the channel's standard error, each lever's share of it times the largest distance that lever's box allows from the log's mean action, where the fit's drift absorbed the channel, as the root mean square of the Euclidean norm over the states of the error it moves the field by, which reads the same in any units of each lever (ADR 0087) and wherever its zero is (ADR 0091), with the drift's own in quadrature, both read at the state each step of the plan starts from, a standard error and not a bound; and the plant's own noise, the plan's one-step error on the log, read off the fit's defect with its lag-1 correlation within units (ADR 0080, DecisionCertificate.tube_noise). The radius holds the two together at each step with probability 0.95 where the noise is Gaussian and AR(1) and the field's error is its standard error times Student's t at the degrees of freedom its spread is read with (ADR 0104). A disturbance that persists and is not logged is read in part as the drift, so the noise read off the log is smaller than the plant's; a tube warning then says the 0.95 is not assured, and the tube does not widen (ADR 0105). Up to 0.16.0 the tube carried the channel's error alone: on 600 one-unit logs shaped like the BOPTEST case's it read 0.051 K one step ahead, where the plant's error one step ahead reached 0.16 to 0.22 K at 95 %; it held the plant at the first step on 40 % of draws and trusted 6 to 13 steps on nine logs in ten. On 0.22.0 it holds the plant at the first step on 96 % to 98 % of draws and trusts 1.9 to 2.8 steps on average by cell, 5 at most, where the plant's error stays within the tolerance of 0.5 K at 95 % for 2 to 4 (scripts/bench_boptest_tube.py cover). A tube whose rate, budget or noise comes out other than a finite number is not evaluated, and a warning says so; as is one on an asserted empty adjustment set, whose observational fit has no channel error, and one over a noisy log in which no unit has two consecutive transitions, which leaves the noise's persistence unread. The tube is one norm over the states, and tolerance one number in their units: states in units unlike each other mix in it, as the levers' once did. To give each state its own scale, log it in units of the error you accept on it, its target, its bounds and the prices with it, which the plan reads the same (ADR 0059), and pass tolerance=1 (ADR 0091).

None
x0 ArrayLike | None

the state to plan from, one finite value per state: the target's, then each constrained column's. Defaults to the mean over units of each unit's last observed state, the pooled "where we are now". Prescription.start records which, and for the panel's, over how many units, at which periods and with what spread.

None
integrator Integrator | None

the one-step map the field is fitted to and planned by, "rk4" or "euler", passed to fit_causal_residual. It is "euler" there by default, deliberately: the low-level fit has no idea what will consume it and keeps its contract, while here the field goes straight to chc.plan.causal_plan, and the plan, its tube, its barrier's audit, its regret bound and every rollout the prescription carries step it by the map it was fitted to: RK4's under "rk4", x + dt f(x, u) under "euler" (ADR 0118). Fitting one map and planning by another is a bias the caller never asked for --- on the plant in chc.research.mmm an Euler fit planned by RK4 costs 28% of the control channel. "rk4" reads a log sampled from a plant in continuous time: its fit is the field whose RK4 step reproduces the log's one-step map. Choose "euler" when the panel is genuinely discrete-time (a weekly budget is not a sample of an ODE) and the one-step map is the model. Where the log keeps less than 0.27 of a mode from one step to the next, no field stepped by RK4 reproduces it, RK4's growth factor being never smaller, and the "rk4" fit raises. Not given, it is "euler" (ADR 0129): the Euler fit gives the barrier an absolute radius, a bound on the channel's error, where an "rk4" fit gives only a relative one. Up to 0.21 it was "rk4".

None
drivers Sequence[Driver]

exogenous columns the plan can forecast but not move, each with its forecast over the horizon (Driver). They are fitted into the drift jointly with the states (fit_causal_residual), and the plan is made against the forecast, so it acts ahead of a push it can see coming. The forecast moves the drift and never the channel, so gamma_star is priced with it in place. Two things are not priced: the forecast's own error, and the fitted gain's standard error, which the tube's model error leaves out as it leaves out the drift's. A forecast outside the range the panel logged is extrapolated by the fitted gain, and logged as a warning.

()
neighbours Mapping[Any, Iterable[Any]] | str | None

the units whose levers may move a unit's states beside its own: a mapping from a unit to its neighbours, or the name of a column grouping the units, each unit's neighbours the others in its group. The fit takes each unit's transitions to depend on its own levers alone; where they do not, as with drivers or customers moving between zones, its channel is the effect of moving one unit with its neighbours held, and a plan that moves them all gets another. Given, the fit's residual is regressed on the neighbours' mean levers within periods (interference_check, experimental): Prescription.interference holds the result, and a rejection at 5 % is logged as a warning and named in the report. It reports; it changes nothing else. Under clusters it names the clusters, not the units.

None
clusters str | None

the name of a column grouping the units, each unit in one group throughout: fit and plan on the groups instead of the units, each group's row in a period the mean of its units' rows logged then (ADR 0113). A spillover between the units of one group is then inside its rows, so the channel is the effect of moving the group's units together, the effect a plan that moves them all gets. A spillover between groups is not: check it with neighbours. The fit has a row per group and period, so its errors read the groups' spread, not the units'. The panel's declared cluster is kept where it holds one value over each group's rows, and dropped otherwise. Prescription.provenance is the grouped panel's.

None
nuisance_knots int | Literal['auto'] | None

the cross-fitted nuisances' spline, passed to fit_causal_residual: "auto", the default, adds a natural cubic spline in each covariate at ceil(N^(1/3)) of its quantiles beside the polynomial, where it predicts the other fold better than the polynomial alone; an integer, that many knots; None, none, the default up to 0.19.0. With None the fit warns where the spline would move the channel by more than 3 errors of the move, more on few clusters or periods. RunProvenance.nuisance_knots records it.

'auto'
tube_actions TubeActions

which actions the tube's field part holds for (TubeActions). "box", the default, any action of the levers' box. "plan", experimental, the plan's own actions alone: the fit's error is carried through the plan's rollout as one vector, S_k Sigma S_k' (Lutkepohl 2005, section 3.5), so the steps' errors cancel where the actions change sign, where the box's form adds their norms. The guarantee narrows with it: a schedule changed after the plan, a lever moved by hand, is outside it. It needs a field affine in the state, whose tube is exact, and a fit that keeps its field's terms; elsewhere a warning says so and the box's form is read. The tube moves no action; the certificate says which form it read (DecisionCertificate.tube_actions, ADR 0138).

'box'
dither str | Sequence[str] | None

the column, or columns, holding the random draw the logger added to the levers, logged: drawn apart from everything the plant reads, at most given the states. Given, the channel is fitted a second time, with the draw as its instrument and the states as its moment's only covariates, never the adjustment set, which may hold a column the levers move; its drift holds the adjustment set's push, as the plan's fit's does, so the two fits differ in what identifies the channel alone (ADR 0159); and the plan's channel is read against it in the plan's own regret (DitherCheck, experimental). Prescription.dither_check holds the result, a rejection at 5 % is logged as a warning and named in the report. It reports; the plan, its fit and its certificate are those without it, bit for bit. A draw that does not move every direction of the channel the log moves, given the states, identifies no channel, and is refused. None, the default, fits nothing more.

None
planned_cost_bias bool

read the planned cost's bias, with its sign, and the corrected cost into the certificate (DecisionCertificate.planned_cost_bias, ADR 0088): the channel is fitted a second time, keeping its influence, whose covariance over every parameter the fit holds is the bias's S (chc.misspecification.planned_cost_bias). Where that refuses --- a plan held under the constraints' barrier, one that meets a bound of its box or a row, one made against drivers, a fit whose channel is not identified --- the field is None and planned_cost_bias_reason holds the refusal. It moves nothing else: the plan, its fit and every other field are those without it, bit for bit. Off by default, since the second fit keeps N n p floats of influence. Experimental.

False
barrier_drift_error bool

read the fit's drift error into the barrier's room, experimental. The deviation a certified step's room is read less then carries, beside the channel's radius, t sqrt(n) drift_error: the fit's drift_error, the standard error of the drift's fitted value at the log's rows, times the root of the number of states, as the tube reads it, at Student's t of 0.975 at the degrees of freedom the tube reads it with. It is passed to chc.plan.certify_safety, and under hold_constraints to chc.plan.BarrierConstraint, as drift_error, and DecisionCertificate.barrier_drift_error holds it. A certified step then holds a plant whose drift is within it of the fitted one, as well as one with the fitted drift; the condition and gamma_star read the fitted drift either way. The price is the certified steps where the drift is unstable: on the 20 logs chc.plan.certify_safety reads, held at gamma = 1.5, they fell from 29.95 to 24.85 on average, and the true plant, which left the set on 1 log without it, left it on none. On 200 such logs it stayed in the set over the certified steps on all 200 with the bound and on 173 without it, 0.865, below the 0.95 the channel's radius states: off, the certificate does not carry the drift's sampling error, a calibration gap of the default, which stays in 1.x since the bound shortens the certified steps, 29.2 to 24.6 on average there (ADR 0119; scripts/bench_drift_room.py). The bound is the error's root mean over the log's rows: at the held plans' states of two of those logs, inside the log's spread, the drift's own error was 0.71 to 0.85 of it, and beyond the spread 1.45 to 1.63 times it (ADR 0104). Off by default, so the room reads the channel's error alone, as up to 1.2, and nothing moves. With no constraint, or on a fit that gives no drift error, the observational one, it raises.

False
inner InnerSolve

how each of the held barrier's rounds is solved, under hold_constraints (experimental): causal_plan's inner (chc.plan.causal_plan). "diagonal", the default, is the descent every held plan took before. "orthant" takes the kink of the held condition's worst case at the log's mean action, the barrier's centre, by its sides, where a plan with one lever under a radius can stall under the descent and under "newton" alike (ADR 0144). Both step on the box alone: where the plan holds linear rows, a lever's cap_per_step, a budget or a combination of the levers the log kept at one level, its rounds take the descent, which holds them, and a warning says so. The record holds the solve asked for, inputs.inner.

'diagonal'

Returns:

Name Type Description
A Prescription

class:Prescription. Read DecisionCertificate.identification before

Prescription

attr:Prescription.schedule, which raises when the effect is not identified.

Prescription

attr:Prescription.run records what the run used (RunProvenance), and

Prescription

meth:Prescription.to_json what the call was asked, which

Prescription

meth:Prescription.from_json replays.

Raises:

Type Description
DecisionError

the decision is mis-specified --- no lever, a lever named twice or also the target or a constraint, a column constrained twice, a target schedule whose length is not horizon, constraints to hold with none given, max_levers below one or with a lever whose box excludes zero, a driver that is also a lever or a state or is named twice, a forecast that is not horizon + 1 finite levels, a budget that does not weigh one spend per lever, starts its periods anywhere but the plan's first step, or allows less than the levers' boxes spend at the least, a dt that is not a finite positive step, an integrator that is neither "rk4" nor "euler", a tolerance that is negative or nan, a gamma below 1 or not finite, which is not a sensitivity level, a radius other than "auto", "absolute" and "relative", or "absolute" on a fit that gives no absolute radius, barrier_drift_error with no constraint or on a fit that gives no drift error, an inner that is none of "diagonal", "newton" and "orthant", or that is not "diagonal" without hold_constraints or over more actions, horizon times the levers, than a Newton round factors, a panel with no consecutive pair of periods to fit a transition on, a cap_per_step on a lever that follows its logged rule or a budget that prices one, max_levers where the log kept a combination of the levers away from zero, an x0 that is not one finite value per state, an asserted adjustment set that names a lever, or a covariate or a driver whose column would be read in a second role: one named u or x_next, or x other than as the one state, under which the transitions hold the levers, the states a period on and the states, or one named for a driver's level a period on, f"{driver}_next"; neighbours that name a unit the panel does not have, or a unit, under clusters a cluster, that clusters or a neighbours column puts in two groups; dither beside hold_constraints or drivers, whose plans have no regret metric to price the contrast in, naming a lever, a state, a driver or a column of the adjustment set, beside levers that follow their logged rule or an asserted empty adjustment set, or a draw that does not identify the channel given the states.

KeyError

a lever, target, constraint, driver, asserted covariate, clusters, a neighbours column or dither names a column the panel does not have. The message lists the panel's columns. Also a graph that has no node for a lever, the target or a constrained column.

PanelError

a column the fit reads as numbers --- a lever's, a state's, a covariate's or a driver's --- holds text, dates, times, durations, complex numbers or any other value that is not a real number, or a number finite in its own type that is an infinity in float64, as chc.panel.Panel.wide refuses it. The message names the column, the value, its unit and its time.

A direction of the channel the log never moves apart from what the states and the covariates predict (unmoved) is not identified on this log, and the plan keeps to what the log did along it (ADR 0054). A lever whose whole channel is so is held at its mean logged level, clipped to its box, where the log kept it at one level, and follows the log's least-squares rule of the state inside the plan's field where the log set it from the state alone; DecisionCertificate.unmoved_levers and rule_levers name them, and the schedule's column carries the rule read along the predicted path. Among the other levers, a combination the log kept at one level is held there by an equality row at every step (relations). A lever or a combination the log set from anything else gives no plan, and neither does a log that moves no lever: the identification is then not_identified, its reason naming the levers and the columns they were set from. The plan is checked exactly: the fits the log cannot tell apart differ along directions in which the field is linear, and first_loaded_step is the first step at one of whose stages any of them moves the field, where the trustworthy prefix ends. estimability says which case holds.

Each decision point emits one logging record on chc.decision, keyed by chc_event (see _log). Nothing is configured here; a caller that wants them calls logging.basicConfig itself. An unidentified effect, a lever the log never moved, one on its logged rule, a combination kept at its logged level, a plan the log does not determine, a run in single precision, a forecast outside the logged range and a planned action outside its lever's logged range come through at WARNING.

Before fitting, the panel is asked whether the levers read anything but the states and their recorded parents: Prescription.logger_check (experimental). It reports, at INFO; it changes nothing else.