BassModel.fit#
- BassModel.fit(data, progressbar=None, random_seed=None, **kwargs)[source]#
Fit the Bass diffusion model via MCMC.
- Parameters:
- data
xr.Dataset,pd.DataFrame,pd.Series,np.ndarray Adoption counts over time. See
to_bass_dataset()for formats.- progressbarbool, optional
Whether to show the progress bar. Defaults to
True.- random_seedoptional
Random seed for reproducibility.
- **kwargs
Additional arguments forwarded to
pymc.sample().
- data
- Returns:
arviz.InferenceDataPosterior 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 az.plot_trace(idata, var_names=["m", "p", "q"]) # Forest plots of peak adoption time az.plot_forest(idata.posterior["peak"], combined=True)
For posterior predictive sampling with new time points:
pp = model.sample_posterior_predictive(X=new_data)