Description Usage Arguments See Also Examples

View source: R/area_under_curve.R

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 xy-coordinates. This function can handle unsorted x values (by sorting x) and ties for the x values (by ignoring duplicates).

1 2 3 |

`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. |

DescTools

1 2 3 4 5 6 7 8 9 10 11 | ```
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")
``` |

```
[1] 0.4980976
[1] 0.4992463
[1] 0.4980982
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.