area_under_curve {bayestestR}  R Documentation 
Area under the Curve (AUC)
Description
Based on the DescTools AUC
function. It can calculate the area under the
curve with a naive algorithm or a more elaborated spline approach. The curve
must be given by vectors of xycoordinates. This function can handle unsorted
x values (by sorting x) and ties for the x values (by ignoring duplicates).
Usage
area_under_curve(x, y, method = c("trapezoid", "step", "spline"), ...)
auc(x, y, method = c("trapezoid", "step", "spline"), ...)
Arguments
x 
Vector of x values. 
y 
Vector of y values. 
method 
Method to compute the Area Under the Curve (AUC). Can be

... 
Arguments passed to or from other methods. 
See Also
DescTools
Examples
library(bayestestR)
posterior < distribution_normal(1000)
dens < estimate_density(posterior)
dens < dens[dens$x > 0, ]
x < dens$x
y < dens$y
area_under_curve(x, y, method = "trapezoid")
area_under_curve(x, y, method = "step")
area_under_curve(x, y, method = "spline")