spec: Calculate the Specificity for predicted probabilities against...

View source: R/spec.R

specR Documentation

Calculate the Specificity for predicted probabilities against a binary outcome.

Description

Calculate the Specificity for predicted probabilities against a binary outcome.

Usage

spec(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 specificity is the probability of a false prediction conditional on a false outcome.

Examples

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

gweissman/gmish documentation built on Sept. 3, 2024, 11:39 p.m.