ControlEffect#

class pymc_marketing.mmm.additive_effect.ControlEffect(**data)[source]#

Additive effect for control variables in the MMM.

Encapsulates the control column logic so that control variables are handled through the MuEffect protocol rather than as inline code inside build_model.

Parameters:
priorPrior, optional

The prior distribution for the gamma_control coefficients. If "control" is absent from the prior’s dims it is automatically added so each control column receives its own independent coefficient. Defaults to Normal(mu=0, sigma=2, dims="control").

date_dim_namestr, optional

The name of the date dimension in the model. Default is "date".

Examples

Standalone usage (the MMM wires this automatically when control_columns is provided, but you can also construct it explicitly):

from pymc_extras.prior import Prior
from pymc_marketing.mmm.additive_effect import ControlEffect

effect = ControlEffect(
    prior=Prior("Normal", mu=0, sigma=1, dims="control"),
)

Methods

ControlEffect.__init__(**data)

Create a new model by parsing and validating input data from keyword arguments.

ControlEffect.construct([_fields_set])

ControlEffect.copy(*[, include, exclude, ...])

Returns a copy of the model.

ControlEffect.create_data(mmm[, X])

Register control data in the PyMC model.

ControlEffect.create_effect(mmm)

Create the control contribution deterministic in the model.

ControlEffect.dict(*[, include, exclude, ...])

ControlEffect.from_dict(data)

Reconstruct from a dict.

ControlEffect.from_orm(obj)

ControlEffect.json(*[, include, exclude, ...])

ControlEffect.model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

ControlEffect.model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

ControlEffect.model_dump(*[, mode, include, ...])

!!! abstract "Usage Documentation"

ControlEffect.model_dump_json(*[, indent, ...])

!!! abstract "Usage Documentation"

ControlEffect.model_json_schema([by_alias, ...])

Generates a JSON schema for a model class.

ControlEffect.model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

ControlEffect.model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

ControlEffect.model_rebuild(*[, force, ...])

Try to rebuild the pydantic-core schema for the model.

ControlEffect.model_validate(obj, *[, ...])

Validate a pydantic model instance.

ControlEffect.model_validate_json(json_data, *)

!!! abstract "Usage Documentation"

ControlEffect.model_validate_strings(obj, *)

Validate the given object with string data against the Pydantic model.

ControlEffect.parse_file(path, *[, ...])

ControlEffect.parse_obj(obj)

ControlEffect.parse_raw(b, *[, ...])

ControlEffect.schema([by_alias, ref_template])

ControlEffect.schema_json(*[, by_alias, ...])

ControlEffect.set_data(mmm, model, X)

Update control data for new predictions.

ControlEffect.to_dict([_orig])

Serialize to a dict via Pydantic model_dump.

ControlEffect.update_forward_refs(**localns)

ControlEffect.validate(value)

Attributes

model_computed_fields

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_extra

Get extra fields set during validation.

model_fields

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

prior

date_dim_name