Summary
The default priors on BayesianBasisExpansionTimeSeries (and its sub-components LinearTrend + YearlyFourier/WeeklyFourier) assume data on smaller magnitudes. When fit on time series with magnitude ~10⁴ or larger, the posterior collapses and the counterfactual is essentially a flat line at the intercept, with no trend or seasonality picked up at all.
Nothing in the docs or warnings flags this and basically causes a silent failure.
Solutions could include target scaling or scaling priors based on the pre-intervention dataset
Reproducer
import numpy as np, pandas as pd, causalpy
from causalpy.pymc_models import BayesianBasisExpansionTimeSeries
from pymc_marketing.mmm import WeeklyFourier
rng = np.random.default_rng(0)
n = 800
dates = pd.date_range("2023-01-01", periods=n, freq="D")
# realistic-scale series: trend + weekly seasonality + noise
trend = 50_000 + np.arange(n) * 20
weekly = 8_000 * np.sin(2 * np.pi * np.arange(n) / 7)
y = trend + weekly + rng.normal(0, 3_000, n)
df = pd.DataFrame({"treated": y}, index=dates)
model = BayesianBasisExpansionTimeSeries(n_order=6)
its = causalpy.InterruptedTimeSeries(
data=df,
treatment_time=pd.Timestamp("2024-12-01"),
formula="treated ~ 1",
model=model,
)
its.plot() # → near-flat line; no trend, no weekly cycle
Summary
The default priors on BayesianBasisExpansionTimeSeries (and its sub-components LinearTrend + YearlyFourier/WeeklyFourier) assume data on smaller magnitudes. When fit on time series with magnitude ~10⁴ or larger, the posterior collapses and the counterfactual is essentially a flat line at the intercept, with no trend or seasonality picked up at all.
Nothing in the docs or warnings flags this and basically causes a silent failure.
Solutions could include target scaling or scaling priors based on the pre-intervention dataset
Reproducer