# Pymc marketing sample\_posterior\_predictive (Bug)

**URL:** https://discourse.pymc.io/t/pymc-marketing-sample-posterior-predictive-bug/17371
**Category:** v5
**Tags:** bug, pymc-marketing
**Created:** [October 8, 2025, 5:53pm UTC](https://discourse.pymc.io/t/pymc-marketing-sample-posterior-predictive-bug/17371 "2025-10-08T17:53:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![fountainpen](https://avatars.discourse-cdn.com/v4/letter/f/59ef9b/32.png) [@fountainpen](https://discourse.pymc.io/u/fountainpen)
#### Post date: [October 8, 2025, 5:53pm UTC](https://discourse.pymc.io/t/pymc-marketing-sample-posterior-predictive-bug/17371/1 "2025-10-08T17:53:50Z")

</div>

Version: 0.16.0

When using mmm.sample\_posterior\_predictive setting original\_scale=True will only affect ‘y’ variable like so

```python
if original_scale:
    if hasattr(self, "target_scale"):
        # Use the new computed scale factor approach
        if self.output_var in posterior_predictive_samples:
            posterior_predictive_samples[self.output_var] = (
                posterior_predictive_samples[self.output_var]
                * self.target_scale
            )

```

where self.output\_var is

```python
    @property
    def output_var(self) -> Literal["y"]:
        """Define target variable for the model.

        Returns
        -------
        str
            The target variable for the model.
        """
        return "y"

```

That means `posterior_predictive_samples['channel_contribution']`is never affected by the scale parameter. This has downstream affects with other functions such as `plot_budget_allocation` where by default original\_scale=True and channel calculation is calculated with

```python
channel_contribution = (samples["channel_contribution"].mean(dim=["date", "sample"]).to_numpy())

if not original_scale:
    channel_contribution /= self.get_target_transformer()["scaler"].scale_

```

However if passing values from `posterior_predictive_samples` samples[“channel\_contribution”] is never scaled to begin with so original\_scale will not have the desired effect.

For example if someone is following the end to end notebook with the latest pymc marketing version they will not arrive at correct values as the workflow is using these functions in tandem.

Functions used:

[sample response distribution link](https://www.pymc-marketing.io/en/stable/_modules/pymc_marketing/mmm/mmm.html#MMM.sample_response_distribution)

[plot budget allocation link](https://www.pymc-marketing.io/en/0.16.0/_modules/pymc_marketing/mmm/mmm.html#MMM.plot_budget_allocation)

[sample posterior predictive link](https://www.pymc-marketing.io/en/stable/_modules/pymc_marketing/mmm/mmm.html#MMM.sample_posterior_predictive)
