pbetaDiff: Differentiate Regularized Incomplete Beta Function.

View source: R/RcppExports.R

pbetaDiffR Documentation

Differentiate Regularized Incomplete Beta Function.

Description

Calculate the derivatives of the regularized incomplete beta function that is a cumulative distribution function of the beta distribution.

Usage

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 the q argument of the pbeta function.

p

similar to the shape1 argument of the pbeta function.

q

similar to the shape2 argument of the pbeta function.

n

positive integer representing the number of iterations used to calculate the derivatives. Greater values provide higher accuracy at 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 the control parameters. Currently not intended for the users.

Details

The function implements a differentiation algorithm of R. Boik and J. Robinson-Cox (1998). Currently only the first-order derivatives are considered.

Value

The function returns a list which has the following elements:

  • dx - a numeric vector of the derivatives with respect to each element of x.

  • dp - a numeric vector of the derivatives with respect to p for each element of x.

  • dq - a numeric vector of the derivatives with respect to q for each element of x.

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.

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 derivatives
delta <- 1e-6
x <- c(0.01, 0.25, 0.5, 0.75, 0.99)
p <- 5
q <- 10
out <- pbetaDiff(x = x, p = p, q = q)
p0 <- pbeta(q = x, shape1 = p, shape2 = q)

# Derivatives with respect to x
p1 <- pbeta(q = x + delta, shape1 = p, shape2 = q)
data.frame(numeric = (p1 - p0) / delta, analytical = out$dx)
  
# Derivatives with respect to p
p1 <- pbeta(q = x, shape1 = p + delta, shape2 = q)
data.frame(numeric = (p1 - p0) / delta, analytical = out$dp)

# Derivatives with respect to q
p1 <- pbeta(q = x, shape1 = p, shape2 = q + delta)
data.frame(numeric = (p1 - p0) / delta, analytical = out$dq)


mnorm documentation built on April 14, 2026, 5:07 p.m.

Related to pbetaDiff in mnorm...