diffusion {diffusion}R Documentation

Fit various diffusion curves.

Description

This function fits diffusion curves that can be of "bass", "gompertz", "gsgompertz" (Gamma/Shifted Gompertz curve) or "Weibull" type.

Usage

diffusion(
  y,
  w = NULL,
  cleanlead = c(TRUE, FALSE),
  loss = 2,
  cumulative = c(TRUE, FALSE),
  verbose = c(FALSE, TRUE),
  type = c("bass", "gompertz", "gsgompertz", "weibull"),
  method = c("L-BFGS-B", "Nelder-Mead", "BFGS", "hjkb", "Rcgmin", "bobyqa"),
  maxiter = 500,
  opttol = 1e-06,
  multisol = c(FALSE, TRUE),
  initpar = c("linearize", "preset"),
  mscal = c(TRUE, FALSE),
  ...
)

Arguments

y

vector with adoption per period

w

vector of curve parameters (see note). Parameters set to NA will be optimized. If w = NULL (default) all paramters are optimized.

cleanlead

removes leading zeros for fitting purposes (default == TRUE)

loss

the l-norm (1 is absolute errors, 2 is squared errors).

cumulative

If TRUE optimisation is done on cumulative adoption.

verbose

if TRUE console output is provided during estimation (default == FALSE)

type

diffusion curve to use. This can be "bass", "gompertz" and "gsgompertz"

method

optimization method to use. These can be "Nelder-Meade", "L-BFGS-B", "BFGS", "hjkb", "Rcgmin", "bobyqa". Typically, good performance is achieved with "Nelder-Meade" and "L-BFGS-B". "hjkb" and "Rcgmin" might be an alternative for complex shapes but have substantially higher computational costs. For further details on optimization algorithms we refer to the optimx package documentation

maxiter

number of iterations the optimiser takes (default == 5000)

opttol

Tolerance for convergence (default == 1.e-06)

multisol

when "TRUE" multiple optmisation solutions from different initialisations of the market parameter are used (default == "FALSE")

initpar

vector of initalisation parameters. If set to preset a predfined set of internal initalisation parameters is used while "linearize" uses linearized initalisation methods (default == "linearize".

mscal

scales market potential at initalisation with the maximum of the observed market potential for better optimization results (default == TRUE)

...

accepts pvalreps, bootstrap repetitions to estimate (marginal) p-values; eliminate, if TRUE eliminates insignificant parameters from the estimation (forces pvalreps = 1000 if left to 0) sig, significance level used to eliminate parameters.

Value

Returns an object of class diffusion, which contains:

Bass curve

The optimization of the Bass curve is initialized by the linear approximation suggested in Bass (1969).

Gompertz curve

The initialization of the Gompertz curve uses the approach suggested by Jukic et al. (2004), but is adapted to allow for the non-exponential version of the Gompertz curve. This makes the market potential parameter equivalent to the Bass curves and the market potential from Bass curve is used for initialization.

Gamma/Shifted Gompertz

The curve is initialized by assuming the shift operator to be 1 and becomes equivalent to the Bass curve, as shown in Bemmaor (1994). A Bass curve is therefore used as an estimator for the remaining initial parameters.

Weibull

The initialization is obtained through by a linear approximation median-ranked OLS described in Sharif and Islam 1980.

Note

vector w needs to be provided for the Bass curve in the order of "m", "p", "q", where "p" is the coefficient of innovation, "q" is the coefficient of imitation and "m" is the market size coefficient.

For the Gompertz curve, vector w needs to be in the form of ("m", "a", "b"). Where "a" is the x-axis displacement coefficient, "b" determines the growth rate and "m" sets, similarly to the Bass curve, the market potential (saturation point).

For the Shifted-Gompertz curve, vector w needs to be in the form of ("m", "a", "b", "c"). Where "a" is the x-axis displacement coefficient, "b" determines the growth rate, "c" is the shifting parameter and "m" sets, similarly to the Bass curve, the market potential (saturation point).

For the Weibull curve, vector w needs to be in the form of ("m", "a", "b"). Where "a" is the scale parameter, "b" determines the shape. Together, "a" and "b" determine the steepness of the curve. The "m" parameter sets the market potential (saturation point).

Parameters are estimated by minimising the Mean Squared Error with a subplex algorithm from the optimx package. Optionally p-values of the coefficients can be determined via bootstraping. Furthermore, the bootstrapping allows removing insignificant parameters from the optimization process.

Author(s)

Oliver Schaer, info@oliverschaer.ch,

Nikolaos Kourentzes, nikolaos@kourentzes.com

References

See Also

predict.diffusion, plot.diffusion and print.diffusion.

seqdiffusion for sequential diffusion model fitting across product generations.

Examples

 fitbass <- diffusion(diff(tsChicken[, 2]), type = "bass")
 fitgomp <- diffusion(diff(tsChicken[, 2]), type = "gompertz")
 fitgsg <- diffusion(diff(tsChicken[, 2]), type = "gsgompertz")
 fitgwb <- diffusion(diff(tsChicken[, 2]), type = "weibull")
 
 # Produce some plots
 plot(fitbass)
 plot(fitgomp)
 plot(fitgsg)
 plot(fitgwb)


[Package diffusion version 0.4.0 Index]