mixdyn.transforms¶
Transforms of a panel's columns before a model reads them.
Adstock = Geometric | WeibullCdf
¶
Shape = TanhShape | HillShape
¶
Geometric(theta)
dataclass
¶
Each period keeps theta of the carryover it received, 0 <= theta < 1.
theta
instance-attribute
¶
Hill(alpha, gamma)
dataclass
¶
WeibullCdf(shape, scale)
dataclass
¶
HillShape(slope)
dataclass
¶
a^n / (a^n + K^n): half its ceiling at K, S-shaped where its slope n passes 1.
Raises:
| Type | Description |
|---|---|
ValueError
|
on a slope that is not positive and finite. |
slope
instance-attribute
¶
TanhShape()
dataclass
¶
tanh(atanh(1/2) a / K): concave from no spend, half its ceiling at K.
Transform(retention, half_saturation, shape, length)
dataclass
¶
A channel's spend carried over by a normalised geometric kernel of retention and length
periods, then saturated by a curve of shape that is half its ceiling where the adstock is
half_saturation, in the spend's currency.
Raises:
| Type | Description |
|---|---|
ValueError
|
on a retention outside |
retention
instance-attribute
¶
half_saturation
instance-attribute
¶
shape
instance-attribute
¶
length
instance-attribute
¶
kernel()
¶
The carryover as chc.response reads it.
Raises:
| Type | Description |
|---|---|
ValueError
|
on JAX in single precision. |
curve()
¶
The saturation as chc.response reads it, its scale the half-saturation point's.
Raises:
| Type | Description |
|---|---|
ValueError
|
on JAX in single precision. |
channel(coefficient)
¶
The channel coefficient * curve(kernel(spend)), as chc.allocation plans on it.
Raises:
| Type | Description |
|---|---|
ValueError
|
on JAX in single precision. |
column(spend)
¶
The saturated adstock of a (T,) spend series, nothing spent before it: the column a
model's coefficient multiplies.
Raises:
| Type | Description |
|---|---|
ValueError
|
on a spend series that is not a nonempty vector of finite values at or above 0, or JAX in single precision. |
carry_over(spend, adstock)
¶
The adstock of a (T,) spend series, its kernel as long as the series.
channel(adstock, hill, half, coefficient, length)
¶
The channel coefficient * saturate(carry_over(spend)) in chc.response's terms, its kernel
length periods long.
half_saturation(hill, window)
¶
K, gamma times the most of a window's adstocked values.
Raises:
| Type | Description |
|---|---|
ValueError
|
when the window is dark throughout, so |
robyn_weibull(shape, scale, length)
¶
Robyn's CDF Weibull adstock of shape >= 0 and scale in [0, 1], a share of a series of
length periods.
saturate(adstocked, hill, half)
¶
The Hill curve of slope hill.alpha and half-saturation point half at adstocked values.