innovate.diffuse.gompertz module

class innovate.diffuse.gompertz.GompertzModel(covariates: Sequence[str] = None, t_event: float = None)[source]

Bases: DiffusionModel

Implementation of the Gompertz Diffusion Model. This is a wrapper around the SkewedGrowth dynamics model.

bounds(t: Sequence[float], y: Sequence[float]) Dict[str, tuple][source]

Return parameter bounds for the Gompertz model based on observed data and covariates.

The bounds ensure that the main parameters are constrained to meaningful ranges, while covariate effect parameters are unbounded.

Parameters:
  • t (Sequence[float]) – Time points of the observed data.

  • y (Sequence[float]) – Observed cumulative adoption values.

Returns:

Dictionary mapping parameter names to (lower, upper) bounds.

Return type:

Dict[str, tuple]

cumulative_adoption(t: Sequence[float], *params) Sequence[float][source]
differential_equation(t, y, params, covariates, t_eval)[source]

Defines the time derivative for the Gompertz diffusion model, incorporating covariate effects by adjusting parameters at time t.

Parameters:
  • t (float) – Current time point.

  • y (float) – Current cumulative adoption value.

  • params (Sequence[float]) – Model parameters, including base and covariate coefficients.

  • covariates (dict or None) – Optional mapping of covariate names to their time series values.

  • t_eval (Sequence[float]) – Time points corresponding to covariate values.

Returns:

The instantaneous growth rate at time t.

Return type:

float

initial_guesses(t: Sequence[float], y: Sequence[float]) Dict[str, float][source]

Returns initial guesses for the model parameters.

property param_names: Sequence[str]

Return the list of model parameter names, including base parameters and covariate-specific coefficients.

Returns:

List of parameter names for the model, with additional parameters for each covariate in the form ‘beta_a_{cov}’, ‘beta_b_{cov}’, and ‘beta_c_{cov}’.

Return type:

Sequence[str]

property params_: Dict[str, float]

Returns a dictionary of fitted model parameters.

predict(t: Sequence[float], covariates: Dict[str, Sequence[float]] = None) Sequence[float][source]

Predicts cumulative adoption values at specified times using the fitted Gompertz diffusion model.

Parameters:
  • t (Sequence[float]) – Time points at which to predict cumulative adoption.

  • covariates (Dict[str, Sequence[float]], optional) – Time series of covariate values affecting the model parameters.

Returns:

Predicted cumulative adoption values at each time point.

Return type:

Sequence[float]

Raises:

RuntimeError – If the model parameters have not been set via fitting.

predict_adoption_rate(t: Sequence[float], covariates: Dict[str, Sequence[float]] = None) Sequence[float][source]

Predicts the rate of adoption (new adoptions per unit of time).

score(t: Sequence[float], y: Sequence[float], covariates: Dict[str, Sequence[float]] = None) float[source]

Compute the coefficient of determination (R²) between observed data and model predictions.

Parameters:
  • t (Sequence[float]) – Time points at which observations are made.

  • y (Sequence[float]) – Observed cumulative adoption values.

  • covariates (Dict[str, Sequence[float]], optional) – Covariate values for each time point.

Returns:

R² score indicating the proportion of variance explained by the model predictions.

Return type:

float

Raises:

RuntimeError – If the model parameters have not been set.