Calculate derivatives of the regularized incomplete beta function that is a cumulative distribution function of the beta distribution.
pbetaDiff(x, p =10, q =0.5, n =10L, is_validation =TRUE, control =NULL)
Arguments
x: numeric vector of values between 0 and 1. It is similar to q argument of pbeta function.
p: similar to shape1 argument of pbeta function.
q: similar to shape2 argument of pbeta function.
n: positive integer representing the number of iterations used to calculate the derivatives. Greater values provide higher accuracy by the cost of more computational resources.
is_validation: logical; if TRUE then input arguments are validated. Set to FALSE to slightly increase the performance of the function.
control: list of control parameters. Currently not intended for the users.
Returns
The function returns a list which has the following elements:
dx - numeric vector of derivatives respect to each element of x.
dp - numeric vector of derivatives respect to p for each element of x.
dq - numeric vector of derivatives respect to q for each element of x.
Details
The function implements differentiation algorithm of R. Boik and J. Robinson-Cox (1998). Currently only first-order derivatives are considered.
Examples
# Some values from Table 1 of R. Boik and J. Robinson-Cox (1998)pbetaDiff(x =0.001, p =1.5, q =11)pbetaDiff(x =0.5, p =1.5, q =11)# Compare analytical and numeric derivativesdelta <-1e-6x <- c(0.01,0.25,0.5,0.75,0.99)p <-5q <-10out <- pbetaDiff(x = x, p = p, q = q)p0 <- pbeta(q = x, shape1 = p, shape2 = q)# Derivatives respect to xp1 <- pbeta(q = x + delta, shape1 = p, shape2 = q)data.frame(numeric =(p1 - p0)/ delta, analytical = out$dx)# Derivatives respect to pp1 <- pbeta(q = x, shape1 = p + delta, shape2 = q)data.frame(numeric =(p1 - p0)/ delta, analytical = out$dp)# Derivatives respect to qp1 <- pbeta(q = x, shape1 = p, shape2 = q + delta)data.frame(numeric =(p1 - p0)/ delta, analytical = out$dq)
References
Boik, R. J. and Robinson-Cox, J. F. (1998). Derivatives of the Incomplete Beta Function. Journal of Statistical Software, 3 (1), pages 1-20.