This function fits diffusion curves that can be of "bass",
"gompertz", "gsgompertz" (Gamma/Shifted Gompertz curve) or "Weibull" type.
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),
...
)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 is NULL until predict.diffusion is called.
mse insample Mean Squared Error
prew the w of the previous generation
pval p-values for w
init the initial values that have been used for the optimizer
vector with adoption per period
vector of curve parameters (see note). Parameters set to NA will be
optimized. If w = NULL (default) all paramters are optimized.
removes leading zeros for fitting purposes (default == TRUE)
the l-norm (1 is absolute errors, 2 is squared errors).
If TRUE optimisation is done on cumulative adoption.
if TRUE console output is provided during estimation (default == FALSE)
diffusion curve to use. This can be "bass", "gompertz" and "gsgompertz"
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
number of iterations the optimiser takes (default == 5000)
Tolerance for convergence (default == 1.e-06)
when "TRUE" multiple optmisation solutions from
different initialisations of the market parameter are used (default ==
"FALSE")
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".
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.
The optimization of the Bass curve is initialized by the linear approximation suggested in Bass (1969).
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.
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.
The initialization is obtained through by a linear approximation median-ranked OLS described in Sharif and Islam 1980.
Oliver Schaer, info@oliverschaer.ch,
Nikolaos Kourentzes, nikolaos@kourentzes.com
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.
predict.diffusion, plot.diffusion and print.diffusion.
seqdiffusion for sequential diffusion model fitting
across product generations.
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)
Run the code above in your browser using DataLab