Calibration
Calibration lets you add external evidence to a built PanelMMM.
Abacus currently supports two retained calibration paths:
- lift-test measurements through
add_lift_test_measurements(...) - cost-per-target calibration through
add_cost_per_target_calibration(...)
General rule
Both calibration methods operate on a built model, not a bare constructor.
Typical sequence:
If you try to add calibration before the model graph exists, Abacus raises an error.
Lift-test calibration
Use add_lift_test_measurements(...) to add external lift measurements against
the modelled saturation behaviour.
Required columns for lift tests
Lift-test data always needs:
channelxdelta_xdelta_ysigma
It also needs:
- every configured entry in
dims - any additional coordinate columns required by the calibrated variables
In practice, time-varying media models usually require date, because the
time-varying multiplier is indexed by date.
What Abacus does
add_lift_test_measurements(...):
- validates the mapping columns
- scales the lift-test channel and target values to the model scale
- maps the rows to the model coordinates
- adds a likelihood term named
lift_measurementsby default
If time_varying_media is enabled, Abacus includes the media temporal
multiplier in the calibrated saturation function automatically.
Practical notes
- Lift measurements must be monotonic in the sense enforced by the calibration graph helpers.
- The calibration distribution defaults to
pm.Gamma. - You can change the registered variable name with
name=....
Cost-per-target calibration
Use add_cost_per_target_calibration(...) when you want soft penalties on
channel cost-per-target values.
Required prerequisites
Before you add cost-per-target calibration:
- build the model
- add
channel_contribution_original_scale
The second step is required because cost-per-target calibration operates against original-scale channel contribution.
Required columns for calibration_data
calibration_data must include:
channelcost_per_targetsigma- every configured entry in
dims
Requirements for data
The data argument is the spend dataset used to compute calibrated cost per
target.
After Abacus reshapes it into xarray form, its coordinates must match the built model’s:
- same shape
- same coordinate labels
- same channel list
If the reshaped spend data does not match the model coordinates, Abacus raises a validation error instead of silently reordering it.
YAML calibration
The YAML builder supports calibration through a top-level calibration: list.
Each step must provide an explicit method plus a params mapping.
Supported YAML calibration methods:
add_lift_test_measurementsadd_cost_per_target_calibration
Example:
Important YAML constraints:
- calibration steps run after
build_model(...) original_scale_varsis applied before calibration- only the supported calibration methods above are available in YAML
distis not supported in YAML yet foradd_lift_test_measurements- other calibration actions should be applied through the Python API until they have explicit YAML support
Choose the right calibration path
Use lift tests when you have measured incremental response data for a specific spend change.
Use cost-per-target calibration when you want the fitted channel contribution to stay consistent with observed cost efficiency.
You can use either or both, provided the model has been built first.
Common pitfalls
- Adding calibration before
build_model(...) - Forgetting to add
channel_contribution_original_scalebefore cost-per-target calibration - Omitting required
dimscolumns from calibration data - Assuming YAML supports every Python calibration argument;
distdoes not currently round-trip through YAML
Next steps
- Read Model Fitting for the fit workflow once the model has been fully specified.
- Read Save and Load if you plan to keep calibrated models on disk.