The public API¶
This page is written by scripts/api_index.py from each package's __all__ and each name's own
documentation, and tests/test_public_names.py fails when the engine and the page disagree. Each
name is listed by the packages that list it, with the first sentence of its docstring; its fields,
methods and the rest are in its docstring. Decisions the names rest on are in docs/adr/.
What is public¶
- A name is public when an
__all__of a package lists it, and so are the fields, methods and properties of the classes these name that do not start with an underscore (ADR 0062). A name reachable only by its module path is not public, however much it is used. - Every public name imports and is documented: by a docstring of its own, the string after a
constant or an alias in the module that defines it, or a page of
docs/that cites it. This page cites every name and so documents none:tests/test_public_names.pylists the names not documented yet, and that list only shrinks.
Versions and deprecation¶
- Before 1.0, a minor release may change the public surface, and only as the removal rule below allows; a patch release never removes or changes a public name. From 1.0, a name leaves only in a major release.
- How a public name is removed: for one minor release it still imports, and using it raises a
DeprecationWarningthat names its replacement and the release it leaves in; it leaves in the minor release after, and the changelog names it under Removed. causal-hybrid-control removes its names the same way. - A renamed class that
savewrites stays in the format's registry under its old key for as long as its old name imports, so files that name it still load.
The file format and the documents¶
saveandload(mixdyn.api.serialize) write and read one format, a zip of a JSON manifest and NumPy arrays; nothing is pickled, and a loaded object equals the saved one to the bit (ADR 0062).FORMAT_VERSIONis 1. It moves when a file the current version wrote would load differently or not at all: a registered class or a field renamed, moved or removed, a field added without a default, or a field's meaning or units changed. Adding a class to the registry, or a field with a default, does not move it.loadreads its own version only and refuses any other, naming both. The release that moves the version reads the previous one too, through a converter, for at least one minor release.- The JSON documents (
dumps,loadsand their schemas) are for callers outside Python. Each names its schema and an integer version, and reading refuses a document of another version. ADR 0063 states when a schema's version moves.
The names, by package¶
mixdyn¶
aggregate: The panel atnodesof its hierarchy, each node a geo of the result.allot_national: The panel withchanneladded, bought nationally: each period's nationalspendsplit over the geosbytheir population.Allotment: How a channel bought nationally is split over the geos, period by period.Baseline: A lever's counterfactual level read off the panel: the least or the most the lever was observed at, over every geo's periods that were not filled.Cadence: The spacing of consecutive periods.ChannelCombine: How the controls of the geos below a node make the node's.Count: The KPI counts events (orders, installs, sign-ups) named byunit.Gap: What a period becomes when a geo has no row for it.GeoIssue: One finding ofread_panel: what it is, how severe, and where.IssueCode: What a finding is about; its value is the code a document ofISSUESwrites.Lever: A control the panel declares a lever: itskind, and the level its contribution is measured against,baseline, the lever's observed least or most or a level given in the control's own units.LeverKind: What a lever is: a column of the panel, not media spend, that moves the KPI.MediaPanel: A KPI, media spend and controls for every geo and period of a regular calendar.NATIONAL: The geo of a panel read without a geo column.PanelError: The data cannot be read as a panel.read_panel: Check one row per geo and period, then read it into aMediaPanel.Revenue: The KPI is revenue in the panel's currency: a return on spend is a ratio of one currency.Severity: Whether a finding stops reading.
mixdyn.api¶
Compute: The compute a decision took as it was recorded: thedeviceit ran on and thewall_secondsthe caller measured.DECISION: A plan on one page, with what it rests on:decision.Decision: A plan on one page, with what it rests on.decision: The decision document ofplan(plan_posterior) forgeoofpanel, namedtitle.dlm_factsheet: The factsheet of the dynamic linear model (mixdyn.models.dlm),fit, fitted togeoofpanel, its returns read offdecomposition, draws of the fit's decomposition (decompose_dlm).dumpsEstimand: What one lift test ofchannelestimated, as a model reads it.estimands: Each test ofestimates, each channel's in the order given, as theEstimandit reads onpanel's calendar, cadence and currency.Event: A step of the decision's progress:whathappenedona date.FACTSHEET: What a fitted model is and what it rests on:factsheet.Factsheet: What a fitted media-mix model is and what it rests on, in fields that follow the Coalition for Innovative Media Measurement's (CIMM) roadmap for media-mix models.factsheet: The factsheet of the one-geo Bayesian modelspec(mixdyn.models.bayes_mmm) fitted togeoofpanel.geo_factsheet: The factsheet of the Bayesian model over geos (mixdyn.models.bayes_geo),fit, fitted to every geo ofpanel, read off the fit asfactsheetreads the one-geo model off its spec.Health: The health checks of a fit (mixdyn.inference.diagnostics.HealthCard), each read against the threshold the caller passed:max_rhat,pppand its Monte Carlo errorppp_se,negative_baseline, and each channel'sshift,widthandconsistency, as the card holds them;thresholdsthe thresholds passed, byHealthCard.flags' keywords, andflagswhether each cell passes, asHealthCard.flagsreads it.Holdout: The periods fromfirsttolast,periodsof them, held out of the fit, and how far its forecast of the KPI missed them:errorby themetricnamed.ISSUES: What reading a panel found:MediaPanel.issues, orPanelError.issues.LIFT_TESTS: What each lift test a model reads estimated:estimands.loadsNextTest: The next set of lift tests by its value to the plan (ExperimentChoice): theverdict, to"test"or to"plan now"; the set'stestsby their labels and theirchannels; the regret they are expected to remove,reduction, and its Monte Carloerror, in the KPI's units; theircost,net_valueandpredicted_net_value, in revenue; andevpi, the value of perfect information, with itsevpi_error, overdrawsouter draws.Period: One period of a reconciliation: itsdate, thekpiobserved, itsparts, each part's contribution in the orderReconciliationnames them, theirtotaland theresidual, the KPI less the total.PowerSummary: How the tests' design was audited before they ran:backtests, the number of placebo windows of the history the design was read on, andmde_lowtomde_high, the range of its minimum detectable effect over them, in the KPI's units.Prior: A prior the model states: theparameterit is on, itsdistributionon the model's scales, and itsprovenance, where its numbers come from.reconcile: The table that sumsparts, each part's contribution to the KPI at each ofdates, to a total in the parts' order, beside thekpiobserved and its residual, the KPI less the total.Reconciliation: The contributions ofpartsto the KPI over the fittedperiods, which sum to each period's total; the KPI is that total and the residual.Refresh: How often the model is fitted again: everyeveryperiods ofcadence, last onlast.render:documentas plain text: its kind on the first line, then each field on a line of its own under its name, a nested one indented below it, an item of a tuple after a dash, anUnfilledone asunfilled:and its reason, and a reconciliation's periods as a table, a period a row.ReturnRange: Achannel's return over a posterior's draws: theirmeanand the centrallevelinterval fromlowtohigh, in the KPI's units a currency unit, andcounts, what the return counts (RoiPrior.counts): the window's contribution over its spend, or the window's spend's whole return with its carryover.ridge_factsheet: The factsheet of the ridge model (mixdyn.models.ridge_mmm),fit, fitted togeoofpanel.Schema: A document type: its name, its version and the declared type of its data.SchemaError: A value or document does not fit its schema; the message names where.sensitivity_line: ADR 0061's line on a channel's sensitivity to an unmeasured confounder: the ridge fit's robustness values and, wherecontrolis named, its coefficient under a confounder as strong as that control; the Bayesian fit'sGamma*and its bound atgamma.Source: A column the model reads: itscolumnname, itsrole("kpi","spend","control"or"calendar"), itsorigin, where its data came from as the caller states it, and thetransformsthe reader and the model ran on it before the likelihood read it, in order.Spend: Achannel's spend a period, in the panel's currency: thecurrentand theplanned.Unfilled: A field of a document with nothing to record, and thereasonit has none.
mixdyn.api.serialize¶
FORMAT: The name a file's manifest gives its format.FORMAT_VERSION: The version of the format this mixdyn writes, and the one version it reads.FormatError: A file that is not one this mixdyn reads: not an archive of the format, of another format version, or naming a class or a value the format does not hold.load: The objectsavewrote topath.REGISTRY: Every class a file may hold, bymodule:qualname.save: Writeobj, an instance of a class inREGISTRY, topathas the format's archive.
mixdyn.calibration¶
Estimates: Lift estimates by channel, as the models take them.experiment_table: Lift estimates as experiments' records, the columnsread_experimentsreads with its estimate a lift: each estimate's lift and standard error, the window its spend changed over by its first and last dates, the periods read after it, its spend and planned spend a period over the window, its geo where it ran in one and its share of the market.lift_table: Lift estimates as PyMC-Marketing's lift table, the columnsread_lift_tablereads: each estimate's lift a changed period and its standard error a changed period, its spend before the test and the change.LiftEstimate: A lift test of one channel as its analysis reported it.LiftSeries: A lift test of one channel read period by period:LiftEstimate's test with its lift over each period of the readout rather than summed.read_experiments: Geo experiments' records as lift estimates onpanel: each record a test ofchannelwhose group spentspenda period againstplannedover its window, the periods fromstarttoendon the panel's calendar, its lift read over the window andcooldownperiods after it atplanned, none where the column is absent.read_lift_table: PyMC-Marketing's lift table as lift estimates onpanel: each row a test that changed the spend fromxtox + delta_xa period forperiodsperiods, its lift read over those andcooldownperiods after atx,delta_ytimesperiodsand its standard errorsigmatimesperiods.
mixdyn.data¶
aggregate: The panel atnodesof its hierarchy, each node a geo of the result.allot_national: The panel withchanneladded, bought nationally: each period's nationalspendsplit over the geosbytheir population.Allotment: How a channel bought nationally is split over the geos, period by period.Baseline: A lever's counterfactual level read off the panel: the least or the most the lever was observed at, over every geo's periods that were not filled.Cadence: The spacing of consecutive periods.ChannelColumnDataCombine: How the controls of the geos below a node make the node's.Count: The KPI counts events (orders, installs, sign-ups) named byunit.Gap: What a period becomes when a geo has no row for it.GeoIssue: One finding ofread_panel: what it is, how severe, and where.IssueCode: What a finding is about; its value is the code a document ofISSUESwrites.KpiUnitLever: A control the panel declares a lever: itskind, and the level its contribution is measured against,baseline, the lever's observed least or most or a level given in the control's own units.LeverKind: What a lever is: a column of the panel, not media spend, that moves the KPI.MediaPanel: A KPI, media spend and controls for every geo and period of a regular calendar.NATIONAL: The geo of a panel read without a geo column.PanelError: The data cannot be read as a panel.read_panel: Check one row per geo and period, then read it into aMediaPanel.recurring_events: The events that recur inpanel's weeks of the year, read off its controlsindicators, each with its direction, 1 where an event raises it and -1 where it lowers it; see the module.RecurringEvents: The eventsrecurring_eventsreads: each one'sweeksof the year, a run of consecutive weeks from 1 to 52, named innames; each week of the year'sposteriorprobability of the event class,(52,), the prior's where the panel holds no week of it; andseparation, the one class's Bayesian information criterion less the two classes', above 0 where two read better and the events are read.Revenue: The KPI is revenue in the panel's currency: a return on spend is a ratio of one currency.Severity: Whether a finding stops reading.
mixdyn.data.feedback¶
spend_feedback: Each ofgeo's channels whose spend varies, read as the module states:gammaand its interval atlevel, 0.8, 0.9, 0.95 or 0.98, the levels whose fixed-b critical values are tabled, and the seasonharmonicsharmonics of a year at the panel's cadence.SpendFeedback: How farchannel's spend ingeoreads the KPI's last period.
mixdyn.decisions¶
Breakdown: How far a plan's effects may be off before its gain over a reference is gone.breakdown: The breakdown factor of each row of channels'gainsover a reference,(..., channels): the common factorr*by which effects must be off, overstated where a channel gains and understated where it loses, for the gains to sum to 0,sqrt(sum g^+ / sum g^-).compare_scenarios: Each ofscenariosover thehorizonperiods after the fit's window, read against the one namedbaselineatdrawsof the posterior and the noise drawn fromseed, both shared by every scenario.Costs: One channel's costs per incremental KPI over a window:spendin currency;incremental, the KPI the window's spend earns wherever it falls, its carryover counted,roiin the KPI's units times the spend;cost_per_kpi, CPIK, the spend over that KPI; andmarginal_cost_per_kpi, the cost of one more incremental KPI at the window's spend.costs:channel's costs per incremental KPI overwindowof its(T,)spend series, nothing spent before it: one overreturns'roiandmarginal_roiin the KPI's units.CvarPlan: A plan of one geo's channels for the most mean gain over a reference in the worstlevelshare of a posterior's draws, and that reference.FlightPlan: A schedule of one geo's channels over periods, the best rate a period beside it, and how each and the status quo score over a posterior's draws.GeoLimits: What a plan may spend, by name.GeoPlan: A plan of every geo's channels, and the current spend it changes.GoalMarginalReturnTarget: The budget at which one more currency unit returnsper_unit: below it a unit returns more, past it less.MarginPlan: A plan of one national history's channels by a margin rule (plan_margins,plan_anchored_margins), and the status quo it moves.media_difference: Whatplan_badds to the KPI overplan_aat each draw,(draws,), read through the channels alone: each draw's channel run over itshistoryand each plan'speriodsperiods of spend and its kernel's reach after them,length - 1periods of no spend, and the difference summed over the plan's periods and the reach.move_between_geos:plan, each geo's spend by channel, withamountofchannel's spend moved fromfrom_geo's cell toto_geo's, at each period where the cells are series; every other cell as it was.pick_by_lift_tests: Each fit's weight when the lift rows alone choose amongfits: 1 on the fit whose leave-one-out log predictive density, by PSIS-LOO, summed over the observations past the KPI's, the geo tests' gaps, the lift estimates and the lift series, is the largest, the first on a tie, and 0 on the others; None where the fits read no such observation.plan_anchored_margins: The plan of the panel's channels overperiodsweeks that spendsbudgetover them withinlimits, each channel's range a week, by the margin rule anchored on each channel's lift tests,estimatesby channel.plan_breakdown: The breakdown factor ofspend, a plan ofgeo's channels a period overperiodsperiods of the panel's cadence, overagainst, or else each channel's mean spend over the geo's lastperiodsobserved periods asplan_posteriorreads the current spend: for the posterior's expected gain and for each draw's, the history's carryover counted in.plan_cvar: The plan ofgeo's channels overperiodsperiods of the panel's cadence that spendsbudgetover them withinlimits, each channel's range a period, for the most mean gain overagainst, the plan in place at this budget, in the worstlevelshare ofdrawsof the readings' draws: the gain's conditional value at risk, the history's carryover counted in.plan_flighting: The schedule ofgeo's channels overperiodsperiods of the panel's cadence that spendsbudgetover them withinlimits, each channel's range in each period, planned on the readings' channels atreading, and the best rate a period beside it; each scored, with the status quo, at every draw.plan_geos: The joint plan of every geo's channels overperiodsperiods of the panel's cadence that spendstarget, a budget over the plan, or meets it, a goal in its place.plan_margins: The plan of the panel's channels overperiodsweeks that spendsbudgetover them withinlimits, each channel's range a week, by the margin rule with no lift test.plan_pooled_geos: The plan of the panel's cells overperiodsweeks that spendsbudgetover them, each cell within its range a week inlimits, by the closed-form model over geos fitted with the geo testsestimates, by channel, if any.plan_posterior: The plan ofgeo's channels overperiodsperiods of the panel's cadence that spendsbudgetover them withinlimits, each channel's range a period, for the most expected worth over the readings' draws, each channel's mean worth read atgridspends evenly across its range.plan_robust: The plan ofgeo's channels overperiodsperiods of the panel's cadence that spendsbudgetover them withinlimitsfor the most expected gain overagainstwhen each channel's effect may be off by a factor in[1/scale, scale], its least over the factors:plan_posterior's search on each channel's mean change in worth over the reference's,x, counted asx / scaleabove 0 andscale xbelow.plan_table: The table ofspend, a plan ofgeo's channels a period overperiodsperiods of the panel's cadence, againstagainst, or else each channel's mean spend over the geo's lastperiodsobserved periods, asplan_breakdownreads the current spend.PlanTable: A plan of one geo's channels against the current spend, one row a channel.PooledGeoPlan: A plan of a geo panel's cells by the model over geos (plan_pooled_geos), and the status quo it moves.portfolio_roi: Several channels' revenue over their spend: each channel'sroiweighted by its spend.PosteriorPlan: A plan of one geo's channels for a posterior's expected return, and the current spend it changes.Range: At leastleastand at mostmost, in the panel's currency;mostmay be infinite.ranges_from_current: Each channel's range a period as a planner states it: at leastleast_shareof itscurrentspend a period, or its floor infloorswhere it has one, and at mostmost_multipletimes its current spend.Readings: A posterior's draws as a planner reads them, each draw weighted.readings:fit's posterior as a planner reads it:drawsof its draws, evenly spaced over its chains' draws in order from the first to the last, or every draw, each weighted alike.Recommendationresponse_curves: Each channel's posterior mean worth and its centrallevelband at each spend a period ofworths, the draws atreadings.weights: the band's ends are the weighted quantiles, each the least worth whose cumulative weight reaches its share, which at equal weights isnumpy.quantile'sinverted_cdf.ResponseCurves: Each channel's worth at each spend a period,(channels, grid), the channels in the readings' order:rates, the spends;mean, the posterior mean worth over the draws at their weights; andlowandhigh, the weighted centrallevelband.ReturnOnSpendTarget: The most budget whose plan gainsper_unitfor each currency unit it spends: a target return on ad spend, read on the gain.Returns: One channel's returns over a window:spendin currency,contributionin revenue, the returns in revenue per currency unit andcarryovera share.returns:channel's returns overwindowof its(T,)spend series, nothing spent before it.ReturnTarget: The least budget whose plan gainsamount, in the channels' units.RobustPlan: A plan of one geo's channels for the least expected gain over a reference when each channel's effect may be off by a factor in[1/scale, scale], and that reference.Scenario: A named spend path over a forecast's horizon:spend, each channel's spend at each period, andcontrols, each control's value at each, a control it does not name held at the baseline's.ScenarioComparison: Scenarios read against a baseline at the same draws, in the panel's units.Spread: A quantity over a posterior's draws:draws,(draws, ...), each draw's value;meantheir mean by the draws' weights;lowandhightheir weighted quantiles at(1 - level) / 2and(1 + level) / 2, each(...).stacked_readings: The fits' stacked posterior as a planner reads it: each fit's weight,weightsor else stacking's on the fits' leave-one-out log predictive densities of the observations their likelihoods read, spread evenly overdrawsof its draws, evenly spaced over its chains, or over every draw.Undefined: A cost with no value, and why.Worths: Each draw's worth of each channel at spends a period across its range:rates,(channels, grid), the spends, andtable,(draws, channels, grid), the worths, the channels in the readings' order.worths: Each draw's worth of each channel ofreadingsoverperiodsperiods of the panel's cadence and its kernel's length after them, atgridspends a period evenly across the channel's range inlimits, the geo's spend in the panel carried in.
mixdyn.experiments¶
After: A test run after the panel, its periods atcurrent, each channel's spend a period under the plan in place, but for the test's change.assign: A design treatingshareof each block's geos, rounded half up, one of a pair and three of a block of five at the default, drawn byseed: the same seed draws the same design.audit_power: The power ofdesign's test ofreadoutperiods afterpre, at each oflifts, read byreadonce over every backtestkpi_history,(geos, periods), holds, by default withread_didon the groups' sums, at a 5 % level; see the module.Balance: Each feature's standardised difference between the treated and the control geos,differences, and thelargestin absolute value.balance: Each offeatures' standardised difference overdesign: the treated geos' mean less the control geos', oversqrt((s_t^2 + s_c^2) / 2),sa group's standard deviation.Blocks: Geos matched intoblocks, each a tuple of rows in the order of the score, and the rowsleft_outof every block.Candidate: A lift test ofchannelbefore it runs: aLiftEstimatewithout its lift, and alabelto name it by.carryover_order: The two-epoch test thatdesign's channel moveskpino further thanorderperiods after a switch,orderthe design's washout by default,kpia value a period of the design or a row a geo of them, summed over the geos; see the module.CarryoverOrder: A switchback test's two-epoch test of its carryover's order: whether the channel still moves the KPIorderperiods after a switch.choose_tests: The set ofcandidatesto run together, in disjoint groups of at most half the market between them, whose cost is at mosttest_budgetand whose net value is the largest, valued asvalue_of_testsvalues one test, its tests' likelihoods multiplied: each candidate's lift read with its own standard normals, the same in every set it is in, drawn from a stream apart fromseed's own.Costdesigns: Each ofchannels' candidates ongeoofpanel, in the order of the channels, the multipliers, the durations and the shares: the channel's spend times the multiplier over the duration, thencooldownperiods at the spend planned, both read, in a group of the share, its standard errornoise's, run aswhensays.ExperimentChoice: The affordable set of tests of the largest net value, and whether to run it.ExperimentValue: The value to the plan ofcandidatesrun together, in disjoint groups, and its cost; one candidate's wherevalue_of_testsreads it.ExperimentValues: Each candidate's value, in the candidates' order, and the plan without a test:plan, its spend a period in the readings' channels' order.Gaussian: Each outer draw's posterior mean worths moved by the Bayes-linear update: each fit's by the covariance of its draws' worths with the lift over the lift's predictive variance.GeoDesign: The rows of thetreatedgeos and of theircontrolgeos.GeoReading: A geo test's reading bymethod: theliftover the readout and its standard errorse, read as a Student t ofdfdegrees of freedom; the two-sided interval[lower, upper]at levelalpha; thep_valueof the same t, two-sided, against no lift; and theverdict, "up" when the interval lies above 0, "down" when below and "inconclusive" when it holds 0.GeoTest: A geo test ofchannelas it ran: in thetreatedgeos against thecontrolgeos, the spend changed from the period datedstartto the one datedend, both included, and read over thereadoutperiods fromstart.Gross: A test's cost as what it puts at risk: a heavy-up's extra spend and the revenue a cut is expected to lose, each counted where it is positive.GroupNoise: The standard deviation of the market's KPI noise a period, as it reaches a group's lift.log_did: The pre/post log-ratio difference in differences of a window and its standard error from placebo windows of the pre-period; see the module.match_controls: Each oftreated's control amongcandidates, one to one, minimising the summed Mahalanobis distance overfeatures, each a value a geo, under the treated and the candidate geos' pooled within-group covariance.Net: A test's cost as its spend change plus the revenue it is expected to lose, held at least atfloor: a cut of a channel returning less than it costs pays for itself, and a cost not above 0 ranks nothing.Noisepair_geos: The geos matched into blocks ofsizeadjacent in the order ofscore, one number a geo, minimising the summed range of the blocks; thelen(score) % sizegeos left out are those that minimise it, the later in the order on a tie.PlaceboNoise: The market's KPI noise a period over the history before a test,residuals, the error a model of the KPI leaves in each period, and thepreperiods each placebo window and the test are studentised over; see the module.Power: The power of a design's test at each oflifts,power, itssize, the share of replications that read a lift where there is none, the minimum detectable lift at 80 %mde, NaN where no lift reaches it, and the count ofwindowsthe history holds.power: The power ofdesign's test ofreadoutperiods afterpreat each oflifts, byrepsreplications drawn fromkpi_history,(geos, periods), byseed, each read byread, by defaultread_didon the groups' sums; see the module.PowerAudit: A design's power over every one of itsbacktests, at a 5 % level: itspowerat each oflifts; itssize, the share of the backtests that read a lift where there is none; the minimum detectable lift at 80 % over them all,mde; and the least and the largest of it read over the first half of the backtests in time and over the second,mde_lowandmde_high.predicted_lift: Each draw's lift ofcandidateat the market's scale,(draws,), in the KPI's units: the channel's coefficient times the gap in its curve over the readout between the spend as the test runs and as planned, each over the share and carried over by the draw's kernel, nothing spent before the candidate's periods.read_did:design's test onpanelread by a difference in differences, its standard error from placebo windows with at leastwarmupperiods before each, or, atvariance="unit_placebo", read by unit placebos over the design's matchedpairs, drawn byseedwhere they are too many to enumerate; see the module.read_pairs:design's test onpanelread by its matchedpairs' own difference in differences and sign-flip randomisation inference, the signs drawn byseedwhere they are too many to enumerate; see the module.read_sdid: A geo test inpanelread by synthetic difference in differences: the geos intreatedtreated from the datestartto the dateend, both read, the geos incontrolthe controls (every other geo where it is None) and every period beforestartthe pre-period.read_switchback:design's test read fromkpiand the channel'sspendas run, each a value a period of the design or a row a geo of them, summed over the geos; see the module.read_synthetic_control:design's test onpanelread by a synthetic control of the treated geos' mean, its weights fitted on the pre-period less its lastblankperiods, its standard error from the gaps' innovations over thoseblankperiods; see the module.read_tbr:design's test onpanelread by Kerman, Wang and Vaver's (2017) time-based regression, its standard error from placebo windows with at leastwarmupperiods before each, atvariance="iid"their predictive variance under independent errors, or, atvariance="unit_placebo", read by unit placebos over the design's matchedpairs, drawn byseedwhere they are too many to enumerate; see the module.Reader: A test's reading of its window: the treated and the control geos' KPI,(geos, periods), the firstpreperiods before the test and the rest its readout, to the effect read and its standard error, the effect 0 where the test changed nothing.Refit: Each set of tests valued bythenat every outer draw, and its posterior refitted with the tests' simulated estimates atdrawsouter draws of each half, evenly spaced: the mean gap between the refitted reductions andthen's there correctsthen's, a multi-fidelity estimate.Reweight: Each outer draw's posterior read by weighing the other chains' draws by the test's likelihood, and asGaussianwhere the weights' effective sample size falls belowess.SdidFit: Synthetic difference in differences on one panel.SdidReading: A geo test as synthetic difference in differences read it.seesaw: Each ofchannels' seesaw candidates ongeoofpanel, in the order of the channels and the shares: the channel's spend timeshighandlowin turn,blockperiods each, overblocksblocks from a high one, thencooldownperiods at the spend planned, all read, in a group of the share, its standard errornoise's, run aswhensays; see the module.stratified_design: The comparator design over the geos ofkpi_history,(geos, periods), for a test ofreadoutperiods read after the history's lastpre: strata ofsizegeos alike in their series' mean, coefficient of variation and slope,candidatesdesigns drawn within them byseed, each treatingshareof a stratum, filtered by the time-based regression's out-of-sample R^2 and an A/A test and the least minimum detectable lift chosen; see the module.StratifiedDesign: The comparator designstratified_designchose: itsdesign, thestratait was drawn within, the count of distinctcandidatesdrawn and of thosekeptby the R^2 and the A/A filters, and the chosen one's out-of-sampler2and its time-based regression's minimum detectable lift by formula,mde, a share of the treated geos' KPI.switchback_design: A switchback test over the periods datedperiods, in blocks ofblockperiods, the channel on inround_half_up(share * blocks)of them, in an order drawn byseedfromnumpy.random.SeedSequence(seed).spawn(1)[0]: the same seed draws the same design.SwitchbackDesign: A switchback test over the periods dateddates, cut into blocks ofblockperiods, the channel on in the blocks whereonis true; the firstwashoutperiods of every block after a switch, and of the first block, are left out of the reading.SwitchbackReading: A switchback test's reading bymethod: theliftover the periods on and its standard errorse, for "randomization" the standard deviation of the lift over the arrangements, for "hac" Newey and West's and for "jackknife" half the gap between its halves' lifts, read as a Student t ofdfdegrees of freedom (infinite for "randomization", which reads no t); the interval[lower, upper]atlevel; thep_valueagainst no lift; theverdict, "up" when the interval lies above 0, "down" when below and "inconclusive" when it holds 0; the count ofarrangementsread, 0 for "hac" and "jackknife", and whether they were allenumerated; and thecarryovercheck, NaN where no block after a switch keeps two periods in each state.synthetic_did: Synthetic difference in differences ony, units by periods, the units flagged intreatedtreated over the lastpostperiods.Updatevalue_of_tests: Each candidate's value to the plan ofgeo's channels that spendsbudgetoverperiodsperiods withinlimits, overdrawsouter draws ofreadings, each candidate's lift read with the same standard normals, drawn from a stream apart fromseed's own, and each outer draw's posterior updated byupdate; each channel's mean worth is read atgridspends across its range.VerdictWhenWithin: A test run inside the panel's history from its periodstart, counted from 0, at the market's spend there but for the test's change.
mixdyn.inference¶
Chains: Each chain's draws after warm-up,(chains, draws)leading, with what each transition did, and each chain's step size and inverse metric as warm-up left them.Diagnostics: Per quantity,rhat,ess_bulkandess_tail.HealthCard: The health of a Bayesian fit of one geo (mixdyn.models.bayes_mmm), each cell its number.LogDensity: A log density on the unconstrained space, up to a constant, and its gradient.Loo:pointwiseis each observation's log predictive density left out,elpdtheir sum andseits standard error;p_loothe log predictive density in sample lesselpd, the effective number of parameters;pareto_keach observation's fitted shape, andk_thresholdthe shape above which its estimate is not to be trusted.loo:log_likelihoodis each draw's log density of each observation,(chains, draws, observations).Psis: Pareto-smoothed importance weights:log_weightsnormalised,pareto_kthe fitted shape of the ratios' tail, infinite where there is none to fit,k_thresholdthe shape above which the weights are not to be trusted, andessKish's effective sample size of the weights,1 / sum w^2, times the draws' relative efficiency.psis: Pareto-smoothed importance sampling of(S,)log importance ratios;efficiencyis the draws' relative efficiencyr_eff, which sets the tail's length and scales the effective sample size.sample: NUTS chains frominitial, one row a chain, each adapting its step size and diagonal metric overwarmuptransitions and keeping thedrawsafter; chaincdraws its random numbers fromnumpy.random.default_rng([seed, c + 1]), so that no chain readsdefault_rng(seed)'s stream, which a caller may draw the starts from.stacking: The stacking weights of models,pointwiseeach one's log predictive density of each observation left out,(models, observations).
mixdyn.inference.sensitivity¶
Benchmark: An observed control's partial R^2: with the channel given the rest of the design,r2_treatment, and with the KPI given the channel and the rest,r2_outcome.BiasBound: A confounder's reach on a coefficient: it explainsr2_outcomeof the KPI's residual variance given the channel and the design, andr2_treatmentof the channel's given the design.msm_sensitivity: The marginal sensitivity model's bounds onchannel's return inposteriorat each ofgammas, its intervals atlevel, andGamma*.MsmSensitivity: A Bayesian fit's channel under the marginal sensitivity model.ridge_sensitivity: Cinelli and Hazlett's sensitivity ofchannel's coefficient infit, its intervals atlevel, read on the least squares of the fitted periods' KPI on the fit's design; a column that does not vary over them is left out with the intercept.RidgeSensitivity: A ridge fit's channel under Cinelli and Hazlett's sensitivity analysis.robustness_value: Cinelli and Hazlett'sRV_qof a coefficient of t-statistictondfresidual degrees of freedom, orRV_{q, alpha}wherealphais given: the share of both residual variances a confounder must explain to move the estimate, or its1 - alphainterval's near end, byqof the estimate.
mixdyn.models¶
BayesFit: The posterior of the model fitted to one geo over a window of the panel's calendar.BayesGeoFit: The posterior of the model fitted to every geo of a panel over a window of its calendar.BayesGeoSpec: The model over geos: the one-geo model's channels, controls, calendar, noise and curves; the scale of the half-normal prior on each channel's log-SD of its effect over the geos; the channels whose deviations arecentred, sampled on the scale of that log-SD; and three opt-in choices, the noise scale's prior,"half-normal"or"log-normal", the geos' bases',"log-normal", above 0, or"normal", and a Hill's slope,"sampled"or"fixed"at 1.BayesMedia: A channel of the panel and the prior on its return.BayesSpec: The model: its channels, its controls, its trend and season if any, its noise, the family every channel's curve is of, and its kernels' length in periods,kernel: by default the longest series the model reads, the panel's calendar or a test's, and otherwise the periods stated, the weights normalised over them and a spend's carryover cut after them (ADR 0082).Bounds: An interval's ends.Calibration: How geo tests entered a fit:estimates, each tested channel's coefficient as its tests alone read it, andweight, a test period's weight against a KPI period, the KPI's noise variance over the tests'.CellResponse: A cell's expected response to its weekly spend over a plan: a mixture of curves, one a kept grid point, each of itsweights,retentions,curvaturesandcoefficients.CheckCodechoose_dlm: Filterspecon one geo at every discount ofgridand choose by one-step likelihood; fit the specs a likelihood-ratio test atleveldoes not reject, forDlmChoice.bounds.ComponentBounds: One interval per component, asComponentsholds one array of draws per component.Components: One array of draws per component: the base (None without a trend), the seasonality (None without a season), and each effect's contribution.Control: A control of the panel, its coefficient held tolower <= 0 <= upper.decompose_dlm: Drawfit's states given all its data,drawstimes, and split each draw's mean into the base, the seasonality and each effect's contribution.DegenerateFitError: The data leave the margin regression degenerate; the message says how.diagnose_dlm: Testfit's one-step errors, watch them for drift, and check its decomposition.DiscountGrid: The discounts to try, per family of blocks: the trend's, the season's, and the effects', one shared by every effect or withPerEffecteach effect's own.DlmChoice: Every spec of a grid filtered on one geo, the one-step likelihood's best, and the specs the likelihood ratio keeps, each with its fit.DlmDecomposition: A fit's components over its periods,(draws, periods)each, from the posterior of its states.DlmDiagnostics: A fit's checks.DlmFit: The model fitted to one geo's calendar.DlmForecast: The KPI over the periods after a fit's data, forecast 1 tohorizonsteps ahead.DlmForecastDraws: Draws of the KPI over the periods after a fit's data,kpi(draws, horizon), and the share of the paths drawn whose signed coefficients kept their signs at every period forecast,acceptance: how hard the signs bind over the horizon, 1 for a fit without them.DlmSpec: The model's structure.Edge: An end of a grid that a kept spec reaches where the parameter goes on past it, so the set the likelihood ratio keeps may stop there short of the data's:parameternames it, such as"trend discount","tv discount"or"tv half-saturation",endis the grid's value there, a half-saturation point's as a multiple of the channel's mean positive spend, andbestsays whether the likelihood's best spec sits there too.Effect: A channel or control of the panel, with a random-walk coefficient and its discount.Finding: A plausibility check the decomposition fails: on which effect, if one, and on which dates.fit_bayes: Draw the posterior ofspecon one geo ofpaneloverwindow, its first and last dates, by default the whole calendar, its likelihood holdingtests, each channel's geo tests,estimates, each channel's lift estimates, andseries, each channel's lift series, if given.fit_bayes_geo: Draw the posterior ofspecon every geo ofpaneloverwindow, its first and last dates, by default the whole calendar, its likelihood holdingestimates, each channel's lift estimates, if given.fit_dlm: Filter and smooth one geo ofpanelthrough the modelspecdescribes.fit_geo_dlm: Fitspecto every geo ofpanel, the geos' spread chosen by the marginal likelihood.fit_margins: Each channel's margin over the weekly history:sales(weeks,),spend(weeks, channels), thepromotionflag and theprice(weeks,), either None where the history holds none, and the adstock'skernellength in weeks; under the mixture of error modelsnoise,MIXTUREby default, and with None as the research code fitted it, whose margins the sales' level moves.fit_nested: Draw both stages' posteriors on one geo ofpaneloverwindow, its first and last dates, by default the whole calendar, asnested_modelreadsestimates, each channel's lift estimates on the KPI, andmediator_estimates, each channel's on the mediator: apart, each stage from a seed spawned fromseed, or, where a lift on the KPI is of a channel of stage one, as one model from a third.fit_pooled_geos: The model over geos (the module) fitted topanelwith each channel's liftestimates, its kernellengthweeks long.fit_ridge: Fitspecto one geo ofpaneloverwindow, its first and last dates, by default the whole calendar, calibrated bytests, each channel's geo tests, if given.forecast_dlm: Forecast thehorizonperiods afterfit's data, every effect's column taken fromplan.forecast_draws:drawsdraws of the KPI over thehorizonperiods afterfit's data, the effects' columns taken fromplanasforecast_dlmtakes them.FourierSeason: Harmonics 1 toharmonicsof a seasonperiodperiods long (52.18 weeks to a year is allowed), counted from the window's first period:season_cos_handseason_sin_heach.geo_effects: Each geo's coefficients at the last period, the national one plus its deviation, with the spread's uncertainty: their mixture over the spread's draws, read as one Student t with the mixture's variance and the last step's degrees of freedom.GeoDlmFit: The model fitted to every geo of a panel.GeoDlmSpec: The model's structure over geos.GeoEffects: Each geo's coefficient on each effect at the last period,(geo, effect): its mean and the central interval holdinglevelof it, mixed over the spread's draws.Lifted: A fit's posterior given its KPI and its tests.LiftReading: The tests a fit reads, each an observation of one coordinate of the state path: testjreads coordinatecoordinates[j]at periodtwith weightweights[j, t], zero outside its readout, and its liftlift[j]has standard errorse[j], both at the market's scale.LinearTrend: A line through the window's periods, bent atknotspoints spaced evenly inside it: the period's placetin the window,trend, and a hingemax(0, t - knot)for each knot,trend_bend_1on.MarginFit: The margins' posterior, the mixture over the retention combinations.Media: A channel of the panel, its spend carried over byadstockand saturated byhill.Mixture: A channel's posterior over its grid, the other channels at their points:points, the kept points as indices intoPOINTS;weights, theirs, summing to 1; andcoefficients, the posterior mean of the channel's coefficient in each geo under each point,(points, geos).NestedFit: Both stages' posteriors over one geo's window:stage_onethe mediator's, its returns in the mediator's units per currency unit, its spec's priors those it was drawn under, andstage_twothe KPI's, the mediator's coefficient among its controls'.NestedSpec: The two stages and the control of the panel that mediates between them.NoiseMixture: The regression's settings under a mixture of error models (the module): the weeks between the trend's interior knots,knot_every; the AR(1) coefficientspersistenceand the AR(1)'s shares of the errors' varianceshare, each pair of them an error model, with white errors once more wherewhite; and the promoted weeks' variance ratiospromoted, each crossed with every one of those.PerEffect: Discounts each effect takes on its own: a grid tries every combination ofvaluesover the effects, the last effect's varying fastest, and counts one parameter an effect.PooledGeoFit: The fit of a panel over geos (the module).RidgeFit: The model fitted to one geo over a window of the panel's calendar.RidgeSpec: The model: its channels, its controls, its trend and season if any, and the ridgepenalty > 0.search_media: Choose each transformed effect's transform ongridand the discounts ondiscountsby the one-step log-likelihood on one geo, and fit every spec filtered that a likelihood-ratio test atleveldoes not reject, or withfittedat most that many of them.Season: Harmonics 1 toharmonicsof aperiodcounted in the panel's periods (52.18 weeks to a year is allowed), with one discount.Statistic: A test's statistic and its p-value under the model.TransformGrid: The transforms a search tries for each channel:retentions,half_saturationsas multiples of the channel's mean positive spend on the geo, the Bayesian model's unit for them, andshapes.transforms_from_bayes: Each channel's transform at its parameters' posterior medians, by channel, asBayesFit.channelsreads them: its retention, its half-saturation point, its curve, a Hill's slope at its median, and the fit's kernel length.Trend: A level (order=1), or a level and a slope (order=2), with one discount.vague_geo_prior: The engine's default prior over geos: weakly informative, on each geo's own scale.vague_prior: The engine's default prior: weakly informative, on the series' own scale.
mixdyn.models.demand¶
DemandProxy: The panel's controlcolumn, a demand proxy such as query volume, in the onerolethis model gives it;searchednames the channels whose spend follows the demand it measures.Reading: What a channel's return is under a demand proxy's role; see the module.Role: What a demand proxy is to the model: a control,"confounder", or left out,"mediator".
mixdyn.transforms¶
Adstockcarry_over: The adstock of a(T,)spend series, its kernel as long as the series.channel: The channelcoefficient * saturate(carry_over(spend))inchc.response's terms, its kernellengthperiods long.Geometric: Each period keepsthetaof the carryover it received,0 <= theta < 1.half_saturation:K,gammatimes the most of a window's adstocked values.Hill: A Hill curve of slopealpha > 0, its half-saturation pointgammatimes the most of the window's adstocked values,0 < gamma <= 1.HillShape:a^n / (a^n + K^n): half its ceiling atK, S-shaped where itsslopenpasses 1.robyn_weibull: Robyn's CDF Weibull adstock ofshape >= 0andscalein[0, 1], a share of a series oflengthperiods.saturate: The Hill curve of slopehill.alphaand half-saturation pointhalfat adstocked values.ShapeTanhShape:tanh(atanh(1/2) a / K): concave from no spend, half its ceiling atK.Transform: A channel's spend carried over by a normalised geometric kernel ofretentionandlengthperiods, then saturated by a curve ofshapethat is half its ceiling where the adstock ishalf_saturation, in the spend's currency.WeibullCdf: The carryover that survives each lag, a Weibull survival ofshapeandscaleperiods.