netdiffuseR icon indicating copy to clipboard operation
netdiffuseR copied to clipboard

bass_f, the derivative of bass_F, in not calculated correctly

Open fobos3 opened this issue 4 years ago • 1 comments

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).

fobos3 avatar Oct 01 '21 04:10 fobos3

Thanks for reporting. Would appreciate a Pull request.

gvegayon avatar Oct 18 '21 20:10 gvegayon