nathanesau nathanesau - 4 months ago 29
R Question

R - Derivative of Log Incomplete Gamma Function

The following functions are available in R:

  • gamma
    to compute gamma function

  • digamma
    to compute derivative of log gamma function

  • pgamma
    to compute incomplete gamma function

  • ? to compute derivative of log incomplete gamma function

I'm wonder what function can compute the derivative of log incomplete gamma function. I noticed the
package has a function
but not sure how to compute the derivative of the log of this function.

If no function exists, is there a simple way to approximate this derivative in


In fact, my comment and Ben Bolker's together give the answer.

I suggested the use of chain rule of derivation:

log(u(x))' = u'(x) / u(x)

then Ben pointed out that the derivative of pgamma (CDF) is just dgamma (PDF). So, we have

dgamma(x) / pgamma(x)

A properly defined function would be

f <- function (x, shape, rate) dgamma(x, shape, rate) / pgamma(x, shape, rate)