Ref#

class pymc_marketing.terms.Ref(name)[source]#

Reference an already-built named variable in the active model.

Lets an effect expression composed outside the model depend on another built effect (e.g. a on the a_scale deterministic) without recreating its variables. Ref resolves at build time and requires the referenced term to be built earlier in traversal order - build once with Named, reference afterwards with Ref.

Ref contributes no coordinates of its own: coordinates must come from the other leaves in the composition or be supplied by the enclosing model.

Parameters:

name (str) – Name of the referenced variable.

Examples

scale = Named("scale", Parameter("raw", prior=Prior("HalfNormal")))
effect = Named("effect", Ref("scale") * other_term)

Methods

Ref.__init__(name)

Ref.add_coords(ds)

Add coordinates to the model during register_data.

Ref.create_variable()

Resolve the referenced variable from the active model.

Ref.from_dict(data)

Reconstruct a reference from its serialized form.

Ref.get_coords(ds)

Return coordinates needed for this term.

Ref.named(name[, dims])

Record this expression as a named deterministic model variable.

Ref.register_data(ds)

Register shared data variables as pmd.Data.

Ref.set_data(ds[, model])

Update shared data variables for out-of-sample prediction.

Ref.sum(dim)

Sum this expression over one named dimension.

Ref.to_dict([_orig])

Attributes

Ref.data_vars

Dataset variables this term reads as shared data.

Ref.frozen_deterministics

Deterministics this term freezes for out-of-sample evaluation.

Ref.name