trapezoidarea: Approximate Area with Trapezoid Rule

Description Usage Arguments Details Value Comment Examples

View source: R/trap_MLestimates.R

Description

trapezoidarea calculates the approximated area under curve, using trapezoidal rule.

Usage

1

Arguments

x, y

Numeric vectors of same length, representing the x and y coordinates of the points.

Details

The function approximates the area bounded by the following 4 curves:

x = a, x = b, y = 0, y = f(x)

a and b are set at the min and max value of given x coordinates. (x, y) are some points on the y = f(x) curve.

Value

Numeric value of the area under curve approximated with trapezoid rule.

Comment

trapezoidarea is used internally in other function(s) of ROCit.

Examples

1
2
3
4
5
6
7
8
9
# Area under rectangle -----------------
trapezoidarea(seq(0, 10), rep(1, 11))

# Area under triangle ------------------
trapezoidarea(seq(0, 10), seq(0, 10))

# Area under normal pdf ----------------
x_vals <- seq(-3, 3, 0.01); y_vals <- dnorm(x_vals)
trapezoidarea(x = x_vals, y = y_vals) # theoretically 1

ROCit documentation built on July 1, 2020, 11:28 p.m.