Response Scale Semantics
Purpose
DSAMbayes models can operate on an identity (level) or log response scale. This page defines how response scale is detected, stored, and used for post-fit reporting, so that operators understand which scale their outputs are on and how KPI-scale conversions work.
Response scale detection
Response scale is determined at construction time by detect_response_scale(), which inspects the left-hand side of the formula:
| Formula LHS | Detected transform | Response scale label |
|---|---|---|
kpi ~ ... |
identity |
response_level |
log(kpi) ~ ... |
log |
response_log |
The detected value is stored in two model-object fields:
.response_transform—"identity"or"log". Describes the mathematical transform applied to the response before modelling..response_scale—"identity"or"log". Used as a label when reporting whether outputs are on the model scale or the KPI scale.
Both fields are set by the constructor and confirmed by pre_flight_checks().
Model scale vs KPI scale
| Concept | Identity response | Log response |
|---|---|---|
| Model scale | Raw KPI units | Log of KPI units |
| KPI scale | Same as model scale | exp() of model scale |
| Coefficient interpretation | Unit change in KPI per unit change in predictor | Change in log(KPI) per unit change in predictor; exact KPI-scale percent change is 100 * (exp(beta) - 1) |
For identity-response models, model scale and KPI scale are identical. For log-response models, fitted values and residuals on the model scale are in log units and must be exponentiated to obtain KPI-scale values.
This is a semilog model, not a log-log model. In DSAMbayes, a coefficient from log(kpi) ~ x means:
So for a one-unit increase in x, the exact KPI-scale percentage change is:
The common shortcut 100 * beta is only a small-coefficient approximation.
Interpreting log-response models
This is the section to use when an analyst asks, “what does the coefficient actually mean on the KPI scale?”
1. Coefficients stay on the model scale
For a model written as:
$$\log(\mathrm{KPI}) = \alpha + \beta x + \cdots$$the coefficient beta returned by get_posterior() and summarised in posterior_summary.csv is a log-KPI coefficient. DSAMbayes does not silently convert coefficient tables into KPI-scale percentage effects.
2. The exact KPI-scale effect depends on the predictor change
For a change of \Delta x in a predictor, the model implies:
Special cases:
- If
\Delta x = 1, the exact percent change is100 * (exp(beta) - 1). - If
xis a binary indicator changing from0to1, use the same exact formula. - The shortcut
100 * betais only acceptable whenbeta * \Delta xis small enough that the approximation error is negligible for the use case.
3. This is not automatically an elasticity
log(kpi) ~ x is a semilog model. The coefficient is an elasticity only if the predictor is also logged, for example log(kpi) ~ log(x).
So in DSAMbayes:
log(kpi) ~ xgives a semilog coefficient.log(kpi) ~ log(x)would be interpreted as an elasticity.
4. Coefficients attach to the modeled column, not necessarily raw spend
DSAMbayes coefficients describe the predictor that actually enters the model matrix.
That matters because in MMM workflows the modeled term is often:
- an adstocked media signal,
- a saturated transform,
- a normalized exposure metric,
- or another user-authored transformed column.
So if your YAML media block points to transformed signal columns, the coefficient is per unit of that transformed signal, not per unit of raw spend. The same caution applies to interactive formula workflows.
5. Use the right output for the question
Use these surfaces consistently:
posterior_summary.csvandget_posterior()for coefficient summaries on the model scale.fitted.csvandobserved.csvfor fitted and observed values on the model scale.fitted_kpi.csv,observed_kpi.csv, andfitted_kpi()for business-facing values on the KPI scale.
For log-response models, posterior_summary.csv is therefore the wrong place to read off a KPI-scale uplift directly. It is the right place to get beta, which you then interpret with 100 * (exp(beta * \Delta x) - 1).
6. DSAMbayes labels KPI-scale conversions explicitly
When DSAMbayes writes KPI-scale outputs for log-response models, it records:
source_response_scale = "log"response_scale = "kpi"conversion_method
This is intended to make it obvious that the values have been back-transformed and to distinguish the default lognormal-mean conversion from the simpler pointwise exp() median-style conversion.
Post-fit accessors and scale behaviour
fitted() — model scale
fitted() returns predicted values on the model scale. For identity-response models this is the KPI scale. For log-response models this is the log scale.
fitted_kpi() — KPI scale
fitted_kpi() applies the inverse transform draw-wise before summarising. For log-response models the default conversion (since v1.2.2) uses the conditional-mean estimator:
This is the bias-corrected back-transform that accounts for the log-normal variance term. The previous behaviour (v1.2.0) used the simpler exp(mu) estimator, which corresponds to the conditional median on the KPI scale. To retain that behaviour, pass log_response = "median":
The output includes source_response_scale (the model’s response scale), response_scale = "kpi", and conversion_method ("conditional_mean" or "point_exp") to label the result.
observed() — model scale
observed() returns the observed response on the model scale after unscaling (if scale=TRUE).
observed_kpi() — KPI scale
observed_kpi() returns the observed response on the KPI scale. For log-response models, this applies exp() to the model-scale observed values.
to_kpi_scale() helper
The internal function to_kpi_scale(x, response_scale) implements the conversion:
- If
response_scale == "log": returnsexp(x). - Otherwise: returns
xunchanged.
This function is used consistently by fitted_kpi(), observed_kpi(), and runner artefact writers.
Runner artefact scale conventions
Runner artefact writers use the response scale metadata to determine which scale to report:
| Artefact | Scale | Notes |
|---|---|---|
fitted.csv |
Model scale | Direct output from fitted() |
observed.csv |
Model scale | Direct output from observed() |
posterior_summary.csv |
Model scale | Coefficient summaries on model scale; for log-response models these are log-KPI coefficients, not KPI-scale effects |
| Fit time series plot | Model scale | Diagnostic plot from fitted.csv plus observed.csv; subtitle states whether the model is levels or semilog and what scale is displayed |
| Fit scatter plot | Model scale | Same as fit time series |
| Diagnostics (residuals) | Model scale | Residuals computed on model scale |
| Budget optimisation outputs | KPI scale | Response curves and allocations reported on KPI scale |
Interaction with scale = TRUE
The scale flag and response scale are orthogonal:
scale = TRUEstandardises predictors and response by centring and dividing by standard deviation before Stan fitting. Coefficients and fitted values are back-transformed to the original scale byget_posterior().- Response scale determines whether the original scale is levels (
identity) or logs (log).
Both transformations compose: a log-response model with scale=TRUE first takes the log of the response (via the formula), then standardises the logged values. Post-fit, draws are first unscaled, then (for KPI-scale outputs) exponentiated.
Jensen’s inequality and draw-wise conversion
When converting log-scale posterior draws to KPI scale, DSAMbayes applies exp() to each draw individually before computing summaries (mean, median, credible intervals). This is the correct Bayesian approach because:
E[exp(X)] ≠ exp(E[X])whenXhas non-zero variance (Jensen’s inequality).- Draw-wise conversion preserves the full posterior distribution on the KPI scale.
- Summary statistics (mean, quantiles) computed after conversion correctly reflect KPI-scale uncertainty.
Practical guidance
- Use identity-response models when the KPI is naturally additive and coefficients should represent unit changes.
- Use log-response models when the KPI is naturally multiplicative, when variance scales with level, or when the response must remain positive.
- Always check
response_scale_label(model)before interpreting coefficient magnitudes. - Do not call log-response coefficients elasticities unless the predictor is also logged. In
log(kpi) ~ x, they are semilog coefficients. - For KPI-scale percentage interpretation, use
100 * (exp(beta) - 1), not100 * beta, unless the coefficient is small enough that the approximation is acceptable. - Use
fitted_kpi()for business reporting; usefitted()for diagnostics. - Do not manually exponentiate posterior means from log-response models. Use
fitted_kpi()orto_kpi_scale()on individual draws.
Cross-references
- Model Classes — constructor and formula conventions
- Priors and Boundaries — scale interaction with priors
- Diagnostics Gates — diagnostics computed on model scale
- Config Schema —
target.*,media,controls, andmodel.scalekeys