Calculates the area under curve based on the trapezoidal integration method.

auc(time, resp)

Arguments

time

A vector with the time numeric variable.

resp

A vector with the response numeric variable.

Value

Returns the area under the curve based on the trapezoidal method.

Examples

x <- 1:5 y <- c(1, 2, 3, 2, 1) plot(y ~ x, type = "o", ylim = c(0, max(y)), asp = 1)
polygon(x = c(x, rev(x)), y = c(y, 0 * y), border = NA, col = "purple")
abline(v = x, h = x, lty = 2, col = "gray")
# Area for the colored region. auc(time = x, resp = y)
#> [1] 8