approxAUC: AUC: numerical integral of a function

approxAUCR Documentation

AUC: numerical integral of a function

Description

Evaluate the Area Under the Curve (AUC) based on discrete observations y = f(x), using interpolation of order 0 (step), 1 (trapezoidal), or 3 (natural cubic splines). The AUC is the integral of a function over an interval [from,to].

Usage

approxAUC(
  x,
  y,
  from,
  to,
  method = "trapezoid",
  subdivisions = 100,
  name = "AUC",
  na.rm = FALSE
)

Arguments

x

[numeric vector] x-values.

y

[numeric vector] image of the x-values by the function.

from

[numeric] lower border of the intergration domain

to

[numeric] upper border of the intergration domain

method

[character] the type of interpolation: "trapezoid", "step" or "spline".

subdivisions

[integer] number of subdivisions to be used when performing numerical integration of the spline. Only relevant when method="spline".

name

[character] how to name the output. Can be set to NULL or FALSE to output a numeric without name.

na.rm

[logical] in presence of missing values, should complete.cases of x and y will be used?

Details

This function is a simplified version of the AUC function from the DescTools package.

Value

a numeric value.

Examples

## same examples as DescTools::AUC
approxAUC(x=c(1,3), y=c(1,1), from = 1, to = 3)

approxAUC(x=1:3, y=c(1,2,4), from = 1, to = 3)
approxAUC(x=1:3, y=c(1,2,4), from = 1, to = 3, method = "step")

x <- seq(0, pi, length.out=200)
approxAUC(x=x, y=sin(x), from = 0, to = pi)
approxAUC(x=x, y=sin(x), from = 0, to = pi, method = "spline")


bozenne/repeated documentation built on July 16, 2025, 11:16 p.m.