innovate.compete.lotka_volterra module

class innovate.compete.lotka_volterra.LotkaVolterraModel(covariates: Sequence[str] = None)[source]

Bases: DiffusionModel

Implementation of the Lotka-Volterra model for competitive diffusion.

This model describes the interaction between two competing technologies or products, where the adoption of each is influenced by the other.

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

Returns bounds for the model parameters.

differential_equation(y, t, params, covariates, t_eval)[source]

Returns the differential equation for the model.

fit(t: Sequence[float], y: ndarray, covariates: Dict[str, Sequence[float]] = None, **kwargs)[source]

Fits the Lotka-Volterra model to the data.

This implementation uses scipy.optimize.minimize to find the best parameters by minimizing the sum of squared errors.

Parameters:
  • t – A sequence of time points.

  • y – A 2D array of observed data, where y[:, 0] is the data for the first technology and y[:, 1] is for the second.

  • covariates – A dictionary of covariate names and their values.

  • kwargs – Additional keyword arguments for scipy.optimize.minimize.

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

Provides initial guesses for the model parameters by performing a linear regression on the linearized Lotka-Volterra equations.

property param_names: Sequence[str]

Returns the names of the model parameters: - alpha1: Growth rate of technology 1 - beta1: Competition parameter from technology 2 to 1 - alpha2: Growth rate of technology 2 - beta2: Competition parameter from technology 1 to 2

property params_: Dict[str, float]

Returns a dictionary of fitted model parameters.

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

Predicts the market share of both technologies over time.

This requires solving a system of ordinary differential equations (ODEs).

Parameters:
  • t – A sequence of time points.

  • y0 – The initial market shares for the two technologies [y1_0, y2_0].

  • covariates – A dictionary of covariate names and their values.

Returns:

An array where each row corresponds to a time point and columns correspond to the market share of each technology.

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

Predicts the rate of change of market share for both technologies.

Parameters:
  • t – A sequence of time points.

  • y0 – The initial market shares for the two technologies [y1_0, y2_0].

  • covariates – A dictionary of covariate names and their values.

Returns:

An array containing the adoption rates for each technology at each time point.

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

Calculates the R^2 score for the model fit.

Parameters:
  • t – A sequence of time points.

  • y – A 2D array of observed data.

  • covariates – A dictionary of covariate names and their values.

Returns:

The R^2 score.