Skip to content

mixdyn.data.feedback

Whether a channel's spend reads the KPI: the endogenous-spend flag (ADR 0074).

A business that sets a quarter's budget from the last quarters' sales, or a bidding rule that raises paid search after a strong week, spends on what the KPI did. Where the KPI's unobserved part persists, as demand does, last period's KPI carries this period's, and a model that reads the spend as set apart from the KPI credits the channel with the demand. Heusch's world (2026, "A Synthetic Benchmark Dataset with Endogenous Marketing Spend for Validating Marketing Mix Models", arXiv:2608.21130) is built so: its budget reads the last two quarters' sales before media, its bidding rule last week's over the ten before, and its baseline carries a sentiment nobody observes.

spend_feedback writes each channel's spend as the business's budget model and its surprise, spend_t = m_t + v_t, with

m_t = a + phi spend_{t-1} + gamma kpi_{t-1} + b t / n + sum_h (c_h cos + s_h sin)(2 pi h t / P)

over the geo's periods t observed with the one before, n the panel's periods and P a year at its cadence, and reads gamma, the spend per unit of the KPI's last period, by least squares. The spend's own last period holds a flighted or slowly planned spend's persistence, so the KPI's last period, which the media's carryover ties to the spend's past, is read beyond it; the trend and the season hold what the calendar sets for both. The standard error is Newey and West's (1987, Econometrica 55(3)): Bartlett weights 1 - j / M to M - 1 = floor(4 (n_read / 100)^(2/9)) lags, so the residuals' autocorrelation and unequal variance are counted, each residual scaled by 1 / (1 - h_t), h_t its period's leverage, as HC3 scales it (MacKinnon and White 1985): a promotion's week holds a KPI far from the rest, and the unscaled error read it too small. The interval's half-width is the error times Kiefer and Vogelsang's (2005, Econometric Theory 21(6)) fixed-b critical value for the Bartlett kernel at b = M / n_read, their cubic in b. Over 1000 seeds of Track M v2's world with its four mechanisms off, Student's interval on the unscaled error put 7.3 % to 8.0 % of a channel's 0.95 intervals off 0; this one puts 5.3 % to 5.7 % (ADR 0074).

Where the interval excludes 0 the spend reads the KPI, and SpendFeedback.issue is an IssueCode.ENDOGENOUS_SPEND warning. Its gamma may be of either sign: a spend raised ahead of a promotion and held back in it reads a strong week's KPI with a fall. It is a flag, not a correction: it says the spend reads the outcome, which is what lets a persistent unobserved demand bias a return, and nothing of how far a return is biased; mixdyn.inference.sensitivity bounds that. A spend that reads the demand of the same period, as paid search's auction volume does, shows here only as far as demand persists; a demand proxy in the model is its remedy (mixdyn.models.demand).

SpendFeedback(geo, channel, gamma, se, lower, upper, level, periods, lags) dataclass

How far channel's spend in geo reads the KPI's last period.

gamma is the spend per unit of the KPI's last period, the spend's own last period and the calendar held, in the panel's currency per unit of the KPI; se its Newey-West standard error and lower and upper its interval at level. periods counts the periods read, each observed with the one before it, and lags the Newey-West lags, M - 1.

geo instance-attribute

channel instance-attribute

gamma instance-attribute

se instance-attribute

lower instance-attribute

upper instance-attribute

level instance-attribute

periods instance-attribute

lags instance-attribute

follows property

Whether the interval excludes 0: the spend reads the KPI.

issue()

The ENDOGENOUS_SPEND warning where the spend reads the KPI, None where not.

spend_feedback(panel, geo, level=0.95, harmonics=3)

Each of geo's channels whose spend varies, read as the module states: gamma and its interval at level, 0.8, 0.9, 0.95 or 0.98, the levels whose fixed-b critical values are tabled, and the season harmonics harmonics of a year at the panel's cadence.

Raises:

Type Description
ValueError

on a geo the panel does not have, a level not tabled, harmonics not from 1 to below half a year's periods, or too few periods observed with the one before for the regression's columns and two degrees of freedom.