Binned Risk Estimates
getBINNEDest.Rd
Calculates bins based on number of evenly spaced bins or n-tiles. Determines average risk within bins, used for risk estimates.
Usage
getBINNEDest(
outcome,
score,
quantiles = NULL,
bins = NULL,
right = TRUE,
errorbar.sem = NULL
)
Arguments
- outcome
Vector of binary outcome for each observation.
- score
Numeric vector of continuous predicted risk score.
- quantiles
Numeric; quantiles to split bins.
- bins
Numeric; number of evenly spaced bins or bin locations.
- right
Logical indicating right closed interval. Defaults to
TRUE
.- errorbar.sem
Scalar numeric representing the number of standard error from the means (SEM) used to calculate risk error bar.
Value
A data frame with 4 columns
(score, score percentile, outcome, estimate).
Additionally, there is an attribute "errorbar" holding the error-bar data if
errorbar.sem
was specified.
Examples
# Read in example data
auroc <- read.csv(system.file("extdata", "sample.csv", package = "stats4phc"))
rscore <- auroc$predicted
truth <- as.numeric(auroc$actual)
getBINNEDest(outcome = truth, score = rscore)
#> score percentile outcome estimate
#> 1 0.1500925 0.1021021 NA 0.11764706
#> 2 0.1833072 0.2012012 NA 0.09090909
#> 3 0.2034668 0.3003003 NA 0.09090909
#> 4 0.2232864 0.4024024 NA 0.08823529
#> 5 0.2529264 0.5015015 NA 0.24242424
#> 6 0.2759024 0.6006006 NA 0.30303030
#> 7 0.3000654 0.7027027 NA 0.35294118
#> 8 0.3329956 0.8018018 NA 0.54545455
#> 9 0.3679189 0.9009009 NA 0.27272727
#> 10 0.4471575 1.0000000 NA 0.63636364