sum_contributions_over_time#
- pymc_marketing.data.idata.utils.sum_contributions_over_time(contributions, period)[source]#
Sum per-date contributions over the dates of each period.
Every variable of
contributionsis a component the model adds to the linear predictor on every date. A component without adatedim, such as a time-invariant intercept, is repeated on every date ofcontributionsfirst (seebroadcast_over_date()), so that it is counted once per observed date within each period, exactly like the per-date components. The aggregation runs per variable, so each keeps its(chain, draw, date, ...)dim order.Decompose first, then call this: under a nonlinear inverse link the decomposition of the summed linear predictor is not the sum of the per-date decompositions.
- Parameters:
contributions (
Dataset) – One data variable per component, on the original dates.period (
Literal['original','weekly','monthly','quarterly','yearly','all_time']) – Time period to sum over."original"returnscontributionsunchanged,"all_time"removes thedatedim; otherwisedateholds the last calendar day of each period. A period shorter than the spacing of the dates (e.g."weekly"on monthly data) leaves empty periods, which areNaN.
- Return type:
xr.Dataset- Returns:
The contributions of each period.