Panel Dimensions
Use dims when your dataset is a panel rather than a single timeseries.
Examples of useful panel dimensions:
geobrandmarketcountry
For the input row layout, see Panel Data Layout.
What dims does
dims tells PanelMMM which extra categorical axes exist alongside date.
With no extra dims, the model is indexed by:
datechannel- optionally
control
With dims=("geo",), the model is indexed by:
dategeochannel- optionally
control
With dims=("geo", "brand"), it is indexed by:
dategeobrandchannel- optionally
control
What changes inside the model
Setting dims changes the coordinates and parameter shapes used in the PyMC
graph.
| Quantity | No extra dims | dims=("geo",) |
|---|---|---|
channel_data |
("date", "channel") |
("date", "geo", "channel") |
target_data |
("date",) |
("date", "geo") |
channel_contribution |
("date", "channel") |
("date", "geo", "channel") |
control_contribution |
("date", "control") |
("date", "geo", "control") |
intercept prior dims by default |
() |
("geo",) |
Reserved names
Do not use these names in dims:
datechannelcontrolfourier_mode
Abacus rejects them because they are reserved for internal coordinates.
dims does not imply automatic pooling
This is the most important modelling point.
By default, dims gives you parameters indexed by the panel coordinates, but
not automatic hierarchical shrinkage across those coordinates.
For example:
- the default intercept prior is
Normal(..., dims=dims) - transform priors default to
(*dims, "channel") - control coefficients default to
(*dims, "control")
Those defaults create per-slice parameters. If you want hierarchical pooling
across geo, brand, or another dimension, you need to encode that in the
priors you supply.
Example: independent panel slices
With this specification, the default priors are geo-indexed, but not hierarchical by default.
Example: explicit hierarchical prior
If you want hierarchical structure, define it in the prior itself.
You can do the same for transform priors and additive effects.
Mundlak CRE and panel dimensions
use_mundlak_cre=True only makes sense when you have at least one panel dim.
Abacus enforces that.
When enabled, Abacus builds extra correlated-random-effects terms from training period means:
channel_mundlak_contributioncontrol_mundlak_contributionmundlak_contribution
These terms live on the panel coordinates defined by dims.
Custom HSGP dims
If you use a custom SoftPlusHSGP for time-varying effects, its dims must be
compatible with the panel structure.
Examples:
- no extra dims:
("date",)or("date", "channel")for media dims=("geo",):("date", "geo")or("date", "geo", "channel")for media
YAML example
Your dataset must then contain both geo and brand columns.
Common pitfalls
- Using reserved names in
dims - Assuming
dimsimplies automatic partial pooling - Enabling
use_mundlak_crewith no panel dimensions - Forgetting that every
date+dimscombination must be present in the data
Next steps
- Read Priors and Configuration to encode hierarchical priors explicitly.
- Read Panel Data Layout for the required input shape.