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:
- data
xr.Dataset,pd.DataFrame,pd.Series,np.ndarray Adoption counts over time. See
to_bass_dataset()for formats.- method
str 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_kwargs
dict, optional Only used by the variational methods; forwarded to
Approximation.sample.- **kwargs
Additional arguments forwarded to the underlying PyMC routine.
- data
- Returns:
xarray.DataTreePosterior with parameters and deterministics (adopters, innovators, imitators, peak) plus a
fit_datagroup.
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)