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 |
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 |
maxiter |
number of iterations the optimiser takes (default == |
opttol |
Tolerance for convergence (default == 1.e-06) |
multisol |
when |
initpar |
vector of initalisation parameters. If set to |
mscal |
scales market potential at initalisation with the maximum of the
observed market potential for better optimization results (default == |
... |
accepts |
Value
Returns an object of class diffusion
, which contains:
-
type
diffusion curve type used -
call
calls function fitted -
w
named vector of fitted parameters -
y
actuals -
fit
fitted values of model -
frc
forecasts for future periods. This isNULL
untilpredict.diffusion
is called. -
mse
insample Mean Squared Error -
prew
thew
of the previous generation -
pval
p-values forw
-
init
the initial values that have been used for the optimizer
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
For an introduction to diffusion curves see Ord K., Fildes R., Kourentzes N. (2017) Principles of Business Forecasting 2e. Wessex Press Publishing Co., Chapter 12.
Bass, F.M., 1969. A new product growth for model consumer durables. Management Science 15(5), 215-227.
Bemmaor, A. 1994. Modeling the Diffusion of New Durable Goods: Word-of-Mouth Effect versus Consumer Heterogeneity. In G. Laurent, G.L. Lilien and B. Pras (Eds.). Research Traditions in Marketing. Boston: Kluwer, pp. 201-223.
Jukic, D., Kralik, G. and Scitovski, R., 2004. Least-squares fitting Gompertz curve. Journal of Computational and Applied Mathematics, 169, 359-375.
Sharif, N.M. and Islam, M.N. 1980. The Weibull Distribution as a General Model for Forecasting Technological Change. Technological Forecasting and Social Change, 18, 247-256.
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)