BassModel.fit#

BassModel.fit(data=None, *, method='mcmc', progressbar=None, random_seed=None, sample_kwargs=None, **kwargs)[source]#

Fit the Bass diffusion model.

Thin wrapper around ModelFitter.fit(); see there for the full parameter reference.

Parameters:
dataxr.Dataset, pd.DataFrame, pd.Series, np.ndarray

Adoption counts over time. See to_bass_dataset() for formats.

methodstr

Method used to fit the model. One of "mcmc", "map", "demz", "advi" or "fullrank_advi".

progressbarbool, optional

Whether to show the progress bar. Defaults to True.

random_seedoptional

Random seed for reproducibility.

sample_kwargsdict, optional

Only used by the variational methods; forwarded to Approximation.sample.

**kwargs

Additional arguments forwarded to the underlying PyMC routine.

Returns:
xarray.DataTree

Posterior with parameters and deterministics (adopters, innovators, imitators, peak) plus a fit_data group.

Notes

After fitting, use standard ArviZ functions for posterior analysis:

import arviz as az

# Parameter summaries
az.summary(idata, var_names=["m", "p", "q"])

# Trace plots
azp.plot_trace(idata, var_names=["m", "p", "q"])

# Forest plots of peak adoption time
azp.plot_forest(idata.posterior["peak"], combined=True)

For posterior predictive sampling with new time points:

pp = model.sample_posterior_predictive(X=new_data)