Replies: 2 comments 1 reply
-
Hi @mcb00, The pymc-marketing/pymc_marketing/mmm/mmm.py Lines 406 to 412 in 0b27a25 However, you should be able to use the pymc-marketing/pymc_marketing/mmm/mmm.py Lines 485 to 489 in 0b27a25 and the Maybe something like: ...
mmm.fit(X, y)
with pm.Model(coords=mmm.model.coords) as new_model:
# Since this is scaled
channel_data = mmm.model["channel_data"].eval()
pm.Deterministic(
"adstocked_spend",
mmm.adstock.apply(channel_data, dims="channel"),
dims=("date", "channel"),
)
idata = pm.compute_deterministic(mmm.fit_result, var_names=["adstocked_spend"]) EDIT: The Note The channel data can be switched out with custom data as well if needed # To visualize the adstocked spend
import matplotlib.pyplot as plt
from pymc_marketing.plot import plot_curve
idata.adstocked_spend.isel(date=slice(0, 30)).pipe(plot_curve, "date")
plt.show() |
Beta Was this translation helpful? Give feedback.
-
Thanks @williambdean ! This is super helpful. Eventually I realized I can get the Jin et al. 2017 ROAS by doing something like:
This gives posterior samples of the numerator of equation 10 in the paper. Then you can just divide by the spend in the time period to get the period ROAS. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey yall,
I’m trying to replicate the ROAS computation in equation 10 from the Jin et al. (2017) paper using pymc-marketing. The challenge I’m facing is how to correctly compute ROAS when media inputs are time-lagged via adstock. The example notebook uses the channel contributions, but I don't think that will work to get ROAS over a finite time interval as in the paper.
In the paper, the media contribution from channel$m$ at time $t$ , denoted as $\hat{Y}^m_t(x_{t-L+1,m},\dots,x_{t,m})$ , depends on the adstocked media from $t-L+1$ up to $t$ .$(t_0,t_1)$ , we need to compare predicted outcomes under two scenarios:$(t_0, t_1)$ . The pre-change lags $(t_0-L+1, t_0)$ should remain as observed. That means we need to recompute the adstocked spend for this counterfactual media spend from the beginning of the pre-change period $t_0-L+1$ up to the end of the post-change period $t_1+L-1$ .
To compute ROAS over a finite interval
1. Actual observed media spend.
2. A counterfactual where spend is adjusted (e.g. set to zero), but only during the interval
My question is: Is there a way to query a trained pymc-marketing model for in-sample predictions using a custom media spend time series? This would need to allow setting the raw input spend to arbitrary values during the historical period and having the model recompute the adstocked spend so we can isolate incremental effects correctly.
Is there a recommended way to accomplish this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions