Skip to content

sample_posterior_predictive doesn't scale X data #450

@kylejcaron

Description

@kylejcaron

In the docs example for MMMs, the line of code to sample the posterior predictive is

mmm.sample_posterior_predictive(X, extend_idata=True, combined=True)

When X is on the scale of dollars, the data wont get automatically scaled from mmm.sample_posterior_predictive, so it causes the results to be off. The example doesn't run into this problem because channel spend is simulated as X ~ U(0,1). I personally got pretty confused adapting the code. to a real dataset and seeing the posterior predictive plot look so off and had to dig through the codebase to figure out what was going on.

I think the following is a more general approach that would lead to less confusion for now in the docs

mmm.sample_posterior_predictive(mmm.preprocessed_data['X'], extend_idata=True, combined=True)

An alternative to changing the docs could be to scale the X data in the mmm.sample_posterior_predictive method

Metadata

Metadata

Assignees

No one assigned

    Labels

    MMMModelBuilderRelated to the ModelBuilder class and its children

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions