create_bass_model#
- pymc_marketing.bass.model.create_bass_model(t, observed, priors, coords, model=None, ds=None)[source]#
Define a Bass diffusion model for product adoption forecasting.
This function creates a Bayesian Bass diffusion model using PyMC to forecast product adoption over time. The Bass model captures both innovation (external influence like advertising) and imitation (internal influence like word-of-mouth) effects in the adoption process.
The model includes the following components:
Market potential ‘m’: Total number of eventual adopters
Innovation coefficient ‘p’: Measures external influence
Imitation coefficient ‘q’: Measures internal influence
Adopters over time: Number of new adopters at each time point
Innovators: Adopters influenced by external factors
Imitators: Adopters influenced by previous adopters
Peak adoption time: When adoption rate reaches maximum
- Parameters:
- t
pt.TensorLike Time points for which the adoption is modeled.
- observed
pt.TensorLikeorxr.DataArrayorNone Observed adoption data at each time point. If None, only prior predictive sampling is possible. Axis labels are read from the data itself (an
xr.DataArray) or from the model (apm.Dataregistered with dims); anything else, such as a plain array or apm.Datawithout dims, is labelled positionally in(T, ...)order with the extra dims following their first appearance across thelikelihoodprior and the dims thatm,pandqactually built with, in that order. An array laid out the way thelikelihoodprior declares it is therefore read the way it is laid out.- priors
BassPriors Dictionary containing priors or term recipes for: - ‘m’: Market potential prior or term - ‘p’: Innovation coefficient prior or term - ‘q’: Imitation coefficient prior or term - ‘likelihood’: Observation likelihood model
A recipe may carry covariates through
Dotwhen a dataset is passed viads; pass covariates that vary across a dimension such asproduct.m,pandqare built in that order, so a recipe may reference an earlier coefficient withRef; a forward reference fails with an error naming the missing variable.- coords
dict[str,Any] Coordinate values for dimensions in the model, including ‘date’ for the time dimension and any other dimensions included in the prior specifications.
- model
Model, optional An existing PyMC model to use. If not provided, a new model is created with the given coords.
- ds
xr.Dataset, optional Dataset the recipes read covariates from. A recipe references a covariate by name through
Dot, and only the variables a recipe names are registered, so passing the full dataset is safe. Omit it when no recipe carries data. A covariate varying overTis rejected forp/q; see the note above.
- t
- Returns:
ModelA PyMC model object for the Bass diffusion model, containing the variables m, p, q, adopters, innovators, imitators, peak, and the likelihood y.
Notes
The returned model can be used for prior predictive checks, posterior sampling, and posterior predictive checks to forecast product adoption.
The model implements the following mathematical relationships:
\[\begin{split}\text{adopters}(t) &= m \cdot f(p, q, t) \\ \text{innovators}(t) &= m \cdot p \cdot (1 - F(p, q, t)) \\ \text{imitators}(t) &= m \cdot q \cdot F(p, q, t) \cdot (1 - F(p, q, t)) \\ \text{peak} &= \frac{\ln(q) - \ln(p)}{p + q}\end{split}\]