chc.lift¶
Stability tier: experimental.
Lift tests read as structure: a geo test's gap between its groups, period by period, identifies a channel's carryover, the shape of its curve and its size, over the spend the test covered. Experimental.
A geo test changes one channel's spend in one group of regions and leaves another group spending as planned. The groups share everything else -- the season, the other channels, promotions, every demand shock nobody observed -- so the difference of their outcomes is the channel's own::
d_t = M(s_treated)_t - M(s_control)_t + nu_t,
M the channel's return on a spend path (a chc.response.Channel) and nu_t the
groups' own noise (Heusch 2026a). Every parameter of M is in it: the gap's rise when the spend
changes and its decay after carry the carryover, tests at different spend levels carry the curve's
shape, and the gap's size carries the coefficient. A test reduced to one number, its total lift
over its total spend, keeps only the last.
fit_lift fits the equation by least squares over every period of every test, with one noise
scale across them, and gives each parameter a profile-likelihood interval with an F cutoff
(Bates and Watts 1988): exact for a model linear in its parameters and, unlike a Wald interval, it
follows a likelihood that curves. A parameter the tests do not pin runs to its bound, and its
interval says so: a curve the tests never bent has no upper scale.
The curve is identified over the adstock the tests covered, LiftFit.tested_adstock, and
nowhere else. Past it a plan reads the family's shape, not the experiment.
check_observational reads a channel fitted to observational data, where spend follows the
business, against the tests a fit read: an F test of whether the tests' gaps could be the
channel's, and the factor of the lift it predicts that the tests read. Through an analyst's
effect-scale gap the factor gives the least marginal-sensitivity Gamma the tests leave the
observational channel, a floor under the confounding a plan assumes (De Bartolomeis et al. 2024
bound Gamma from below with a trial in the same way).
HONEST SCOPE:
- The noise is one scale, independent across tests, and by default an AR(1) over each test's
periods (
serial="ar1"). A geo gap's noise persists from week to week, and read as independent (serial="independent") it makes the intervals too narrow and the check reject too often: at an AR(1) coefficient of 0.8 the check rejected the true channel in 30% of 200 worlds at 5%, where the AR(1) reading rejected 4.5%. A gap read through a synthetic control or a regression carries an error common to its periods, which neither models. - The groups spend alike on every other channel and answer alike, so a group's spend and outcome divided by its share of the market are the market's (Heusch's scaling).
- The check's
Fis the region the intervals are profiles of: exact for a model linear in its parameters, approximate on a curve. ItsGammabounds the tested channel's confounding; read for a channel no test reached, it assumes the two are confounded alike. - The arithmetic is JAX's, as for the library's other JAX estimators: float64 under
jax_enable_x64, and float32, good to about seven digits, without it.
GeoArm
dataclass
¶
One group of a geo test: the tested channel's spend and the group's outcome. Experimental.
spend runs over the periods before the readout and then the readout, outcome over the
readout. A period's adstock reads the spend of the kernel's length up to it, so the readout's
first periods need the spend before them: a window cut from a longer series, with nothing
before it, understates the adstock at its start (Heusch 2026b). share is the group's share
of the market the channel is modelled at; its spend and outcome are divided by it.
Raises:
| Type | Description |
|---|---|
ValueError
|
on an empty or non-finite series, a negative spend, a spend shorter than the
readout, or a share outside |
history
property
¶
The periods of spend before the readout.
LiftTest
dataclass
¶
A geo test of one channel: a treated group whose spend on it changed and a control group that spent as planned, alike on every other channel. Experimental.
Raises:
| Type | Description |
|---|---|
ValueError
|
when the groups' spend or readout cover different numbers of periods. |
difference
property
¶
The treated group's outcome less the control's, each at the market's scale.
LiftFit
dataclass
¶
A channel fitted to lift tests' gaps, with an interval for each parameter.
Experimental. See fit_lift.
interval(parameter)
¶
parameter's interval, by its name in parameters.
ObservationalCheck
dataclass
¶
An observational channel read against the lift tests a fit read. Experimental. See
check_observational.
rejected
property
¶
Whether the tests reject the channel at level.
least_gamma(cvar_gap)
¶
The least marginal-sensitivity Gamma whose identified set reaches the tests.
In units of the lift the channel predicts, the set is 1 ± (Gamma-1)/(Gamma+1) cvar_gap,
chc.research.sensitivity's radius, cvar_gap the analyst's effect-scale CVaR gap as a
share of that lift. The least Gamma whose set reaches factor_interval inverts
the radius at the interval's distance from 1, as chc.barrier.barrier_gamma_star
does. Less confounding than this the tests refute at level, as a known-null outcome
refutes it in chc.uncertainty.negative_control_gamma given a level: a floor, not
a ceiling.
1.0 when the interval holds 1; inf when it lies cvar_gap or further from 1, so
that no level reconciles the two and the tests refute the model rather than calibrate it;
nan when the channel predicts no gap.
Raises:
| Type | Description |
|---|---|
ValueError
|
when |
fit_lift(tests, channel, *, level=0.95, serial='ar1', ar_estimate='least_squares')
¶
Fit channel to the tests' gaps by least squares, each parameter with a profile-likelihood
interval. Experimental.
channel names the families, its kernel and its curve, and its kernel's and curve's values
are where the fit starts, so give a scale near the spend the tests saw. Every parameter is
fitted: a coefficient of either sign, so a channel that loses sales and one that does nothing
are both answers; a retention in (0, 1] and each scale and shape as its logarithm, within
a factor of e^40 of its start. The coefficient is never searched: the gap is linear in it,
so wherever the rest moves it takes its least-squares value there (variable projection, Golub
and Pereyra 1973), and the template's own is ignored. The periods of every test are stacked,
with one noise variance, estimated.
serial is how a test's noise runs over its periods. "ar1", the default, reads each
test's noise as nu_t = rho nu_{t-1} + e_t, e i.i.d. and one rho for every test, and
fits the gaps through the Prais-Winsten transform, which at the true rho is the independent
problem above (generalised least squares; Prais and Winsten 1954). A geo gap's noise persists
from week to week, and read as independent it makes every interval too narrow: on go-dark tests
whose noise was an AR(1) of coefficient 0.8, the coefficient's 95% interval held the truth in
88.5% of 200 worlds, and check_observational rejected the true channel in 30% at 5%.
rho is the least-squares AR(1) coefficient of the residuals, each test's periods on their
previous one, read again after each refit until it settles (iterated Cochrane-Orcutt); it costs
a degree of freedom, and the intervals and the check take it as known. On those worlds it read
0.78 at 0.8 (sd 0.08), the interval held the truth in 95.5% and the check rejected 4.5%; at
0.5, 98.5% and 5.0%; on independent noise, 96.5% and 6.0%. The estimate reads low, as a
residual's lag-1 correlation does: the fit has spent degrees of freedom on the residuals, and a
test's run is short. Over another 200 such worlds it read -0.046, 0.286, 0.475 and 0.777 at 0,
0.3, 0.5 and 0.8 (Monte Carlo SE 0.006 to 0.010); the check rejected the true channel on 7.0,
5.0, 7.0 and 3.5% and the coefficient's interval held the truth in 95.0, 96.5, 98.0 and 97.0%
(Monte Carlo SE 1.5%). ar_estimate="least_squares", the default, leaves it so: Kendall's
(1 + 3 rho) / T for a series' own mean would add 0.21 at 0.8 where it reads 0.023 low, and
the intervals above already carry the bias. So the reading holds where the noise does not
persist, at a degree of freedom. Each test needs a run of periods for this to read anything:
those tests had 16. LiftFit.ar_coefficient is the estimate and LiftFit.noise_sd
the innovations'.
ar_estimate="median_unbiased" reads rho off its exact law instead (Andrews 1993, carried
to the fit's residual maker; validation/lift_rho_median_unbiased.mac). The statistic is the
least-squares coefficient of the independent fit's residuals r = M nu, M the residual
maker of the fit's Jacobian, and its law at each rho is that of a quadratic form in the
noise with weights of both signs, which Imhof's (1961) inversion reads. rho is where that
law has the statistic as its median, and LiftFit.ar_interval the equal-tailed interval
at level its quantiles give; the gaps are then fitted once through the transform at
rho. It is exact for a model linear in its parameters: on four tests of 16 periods and
three fitted columns, 2000 draws a coefficient, the median read 0.002, 0.305, 0.501 and 0.797 at
0, 0.3, 0.5 and 0.8, where the iterated least squares read 0.032, 0.027, 0.026 and 0.014 low,
and the 90% intervals held the truth in 89.95, 89.75, 90.7 and 90.3% (Monte Carlo SE 0.7%). On
a curve it is first-order: on 400 of the go-dark worlds above a coefficient, its median lay
0.016, 0.011, 0.007 and -0.002 off the truth, the default's -0.017, -0.018, -0.014 and -0.006,
the 90% intervals held the truth in 87.0, 88.7, 88.5 and 89.2% (Monte Carlo SE 1.5%), and the
coefficient's interval and the check moved by at most 1.3 points. Each step of its root-finder
takes one eigendecomposition of a square matrix with a row for every period of every test.
"independent" reads each period's noise alone, and the fit tests the premise it reads: the
residuals' lag-1 correlation within each test, by Breusch and Godfrey's regression of the
residuals on the fit's Jacobian and their own value a period earlier (Breusch 1978; Godfrey
1978), its t two-sided against t(n - p - 1). LiftFit.serial_p_value holds the
p-value, and below 0.05 the fit logs a WARNING that names serial="ar1". On 200 worlds of
four go-dark tests of 16 periods it rejected 5.5 % of independent noise, and 51 %, 93.5 % and
100 % of AR(1) noise at 0.3, 0.5 and 0.8, where the independent reading's check rejected the
true channel on 11 %, 17 % and 30 %.
Each interval holds the values whose profile, the least cost with that value held, lies within
s^2 F_{1, n - p}(level) of the least cost, s^2 the noise variance over n - p degrees
of freedom. A walk out from the estimate finds each end and a root-finder sharpens it; an end
the tests leave open is the parameter's bound, or 0 or inf for a retention, a scale or
a shape that moves a factor of e^20 without reaching the cutoff. Should the walk find a
point cheaper than the fit by a millionth of the cutoff, the fit restarts from there.
Where the least cost lies on the way to a bound, the estimate is where the fit stopped on that way. Tests that never bent the curve are fitted best by a line, which a saturating family reaches only as its scale and coefficient grow without end; noise the size of the effect can be fitted best by a step, a curve saturated at any spend with a carryover gone within a period, which the family reaches as the scale and the retention fall together. The estimate predicts the gaps as the limit does, and its interval, open on the limit's side, is the answer about the parameter.
Raises:
| Type | Description |
|---|---|
TypeError
|
when |
ValueError
|
on no tests, |
RuntimeError
|
when a solve does not converge within 10 000 evaluations, or the profile keeps finding points cheaper than the fit. |
check_observational(fit, observed)
¶
Read observed, a channel fitted to observational data, against the tests fit read.
Experimental.
Two readings of the tests' gaps d, at the fit's level and with its noise variance s^2
over n - p degrees of freedom; of a fit read with serial="ar1", the gaps, and the ones
observed predicts, through the fit's Prais-Winsten transform, at its
LiftFit.ar_coefficient:
- An
Ftest ofobservedas a point of the fit's model: the least squares of the gaps it predicts over the fit's, per parameter, overs^2, againstF_{p, n-p}(Bates and Watts 1988), the joint region the fit's intervals are profiles of. - The factor, the least-squares multiple of the gaps it predicts,
g, that the tests read:c = g.d / g.g, with thetintervalc ± t s / |g|. It is the tested lift over the liftobservedpredicts, each period weighted by what it predicts there, so tests of either sign add rather than cancel;1when the lift is the channel's.
The F rejects a channel whose shape the tests contradict even where its size is right; the
factor says how far its size is off, and ObservationalCheck.least_gamma turns that into
a floor under the confounding. Where spend follows the business an observational fit reads the
business's decisions as the channel's effect, and the tests are what can say so: on Heusch's
generator it reads paid shopping's return at 8.45 against a true 4.20, with an oracle's
controls (Heusch 2026a).
Raises:
| Type | Description |
|---|---|
TypeError
|
when |
ValueError
|
when |