npv: Calculate the Negative Predictive Value for predicted...

View source: R/npv.R

npvR Documentation

Calculate the Negative Predictive Value for predicted probabilities against a binary outcome.

Description

Calculate the Negative Predictive Value for predicted probabilities against a binary outcome.

Usage

npv(preds, obs, thresh = 0.5)

Arguments

preds

A vector of predicted probabilities.

obs

A vector containing the observed binary outcomes (0 or 1).

thresh

The threshold at or above which a prediction is considered positive. Default = 0.5.

Value

The negative predictive value is the probability of a negative outcome conditional on a negative prediction.

Examples

# Generate some predictions
predictions <- runif(1000)
# Generate some binary outcomes
observations <- sample(0:1, size = 1000, replace = TRUE)
# Calculate the Sensitivity
npv(predictions, observations)
# And at a different threshold
npv(predictions, observations, thresh = 0.8)

gweissman/gmish documentation built on Feb. 16, 2025, 8:38 a.m.