mamut86 / diffusion

R package for forecasting with diffusion models
8 stars 7 forks source link

Plots of diffusion models #15

Open config-i1 opened 5 years ago

config-i1 commented 5 years ago

There is a neat plot in case of type="bass" with innovators and imitators, but it seems that this can also be done for other curves. Here's an example with Shifted Gompertz (not compound with Gamma):

a <- 1000
b <- 0.4
c <- 1
p <- exp(-c)
q <- (b-p)/b
t <- c(0:100)/10

plot(t,a*b*exp(-b*t-c*exp(-b*t))*(1+c*(1-exp(-b*t))),type="l",ylab="y(t)",lwd=2)
# Innovators
lines(t,p*a*b*exp(-b*t-c*exp(-b*t))*(1+c*(1-exp(-b*t))),col="darkgreen",lwd=2)
# Imitators
lines(t,q*a*b*exp(-b*t-c*exp(-b*t))*(1+c*(1-exp(-b*t))),col="darkblue",lwd=2)

image

Is it possible to do similar plots for other functions?

mamut86 commented 5 years ago

Thanks a lot for this suggestion! I am not sure it is a good idea to have innovator and imitator coefficients in all diffusion curve types available as they derive at different interpretation than in the Bass diffusion context. For example, your graph presented, the innovator shape looks counterintuitive to the underlying theory where the imitators are dependent on the innovators. However, it might be an interesting addon to the G/SG model which if c = 1, it represents a Bass model and its parameter p and q can readily be derived (see example). In a recent publication, Bemmoar & Zheng (2018, IJF) also uses a G/SG model parametrised with p and q parameters. However, it first needs the implementation of Issue #11, so that one can fix certain parameters.

a <- 15
b <- 0.2
c <- 1 # if c = 1 (Bass model)
p <- b / (1 + a)
q <- (a*b) / (1 + a)

plot(difcurve(50, w = c(a,b,c,1), type = "gsgompertz")[,2], ylab = "y(t)", type = "l", lwd = 2)
# Innovators
lines(difcurve(50, w = c(p,q,1), type = "bass")[,3], col = "darkgreen", lwd = 2)
# Imitators
lines(difcurve(50, w = c(p,q,1), type = "bass")[,4], col = "darkblue", lwd = 2)

gsg