USCCANA / netdiffuseR

netdiffuseR: Analysis of Diffusion and Contagion Processes on Networks
https://USCCANA.github.io/netdiffuseR
Other
85 stars 21 forks source link

bass_f, the derivative of bass_F, in not calculated correctly #30

Open fobos3 opened 2 years ago

fobos3 commented 2 years ago

The bass f function, which is the derivative of F, is calculated using a time interval of 1. This yields inaccurate results.

> bass_f
function (Time, p, q) 
{
    ifelse(Time == 1, bass_F(Time, p, q), bass_F(Time, p, q) - 
        bass_F(Time - 1, p, q))
}

The f function has a closed form equation that should be used instead of the inaccurate numerical differentiation with such large time interval:

(p+q)^2 / p * exp(-(p+q)*20) / ( 1 + q / p * exp(-(p+q)*20))^2

Alternatively, one can simply substitute into the differential equation for F:

f = (1 - F) * (p + q * F).
gvegayon commented 2 years ago

Thanks for reporting. Would appreciate a Pull request.