reward_model
reward_model performs attribution from aggregated signals using a movement/coherence-based reward baseline. It uses the same tabular D_variables structure as auto_mmm.
At a high level, auto_mmm estimates predictive contribution with the automatic MMM engine, while reward_model estimates contribution from directional movement coherence between signals and the target.
Input structure
Data should contain:
- a timestamp column
- one target column, passed separately through the
targetparameter - one or more signal columns used as attribution inputs
D_variables should be a table/data frame with one row per non-target signal variable and these columns:
| COLUMN | DESCRIPTION |
|---|---|
| variable | Name of the signal column in Data. |
| channel | Final attribution channel associated with the signal. Multiple variables can map to the same channel. |
| measure | Measure type for the signal, such as impressions, clicks, cost, direct_searches, platform_signal, or another supported measure label. |
The old D_measures parameter is no longer used. Measure information must be provided inside D_variables.
Example D_variables structure:
variable channel measure
direct_searches direct direct_searches
facebook_impressions facebook_ads impressions
facebook_cost facebook_ads cost
google_impressions google_ads impressions
google_clicks google_ads clicks
google_cost google_ads cost
Parameters
| PARAMETER | TYPE | DEFAULT | DESCRIPTION |
|---|---|---|---|
| Data | data.frame | Aggregated dataset with timestamp, target, and input signal columns. | |
| D_variables | data.frame / table | Table with variable, channel, and measure columns. | |
| target | str | "conversions" | Name of the target column in Data. |
| max_p | int | 12 | Maximum lag length considered when the model evaluates delayed effects. |
| seed | int | 1234567 | Random seed for reproducible results. |
| verbose | int / bool | 1 | Controls runtime logging. |
| server | str / list[str] | app.channelattribution.io | Server endpoint used by the hosted computation service. |
| password | str | NULL / None | Authentication token for the hosted service. |
| return_diagnostics | bool | FALSE / False | If enabled, returns attribution together with diagnostic objects for advanced inspection. |
Scoring summary
For each channel and lag, reward_model evaluates directional coherence between the lagged signal and the target. The lag score uses the number of non-zero observations used for the lag as a reliability factor:
score_lag = n0 / (n0 + 10) * coherence_rate
where n0 is the number of non-zero observations used to evaluate the current lag. The selected channel score is then converted into a score_multiplier through the shared median/blend scoring logic.
Output
If return_diagnostics = FALSE, the function returns an attribution data frame.
If return_diagnostics = TRUE, the function returns a list/dict containing:
| OUTPUT | TYPE | DESCRIPTION |
|---|---|---|
| attribution | data.frame | Channel attribution by time period. |
| base_raw | data.frame / object | Raw baseline attribution output before final adjustments. |
| score_multiplier | dict / object | Score multiplier information used during attribution assembly. |
| applied_score_multiplier | dict / object | Effective multiplier applied to the returned attribution. |
| individual_scores | dict / object | Channel-level movement/coherence scores selected from the lag evaluation. |
| mode | str | Execution mode metadata. |
| diagnostics | list / dict | Additional diagnostics intended for advanced inspection. |