trueposrate: True positive classification

Description Usage Arguments Details Examples

View source: R/mMisc.R

Description

Returns the rate at which true positives are identified in a classification problem given a certain threshold. Especially for logistic/poisson regression whether a model correctly classifies a binary outcome depends on the threshold.

Usage

1
trueposrate(threshold, truth, fitted)

Arguments

threshold

a value between 0 and 1 for the value at which an outcome is classified

truth

a vector of [0 | 1] values representing the true classification

fitted

a vector in the range [0,1] values representing the predicted classification

Details

This function is primarily used to calculate values for the Receiver Operating Characteristics (ROC) curve function.

Examples

1
2
3
4
5
6
m0 = glm(outcome ~ predictor1 + predictor2, family = binomial(), data = train)
testprobs = predict(m0, newdata = test, type = "response")
truth = train$outcome
trueposrate(0.5, truth, testprobs)
# Most useful for understanding the rate of true positives across a range of thresholds
sapply(0:10 / 10, function(x) {trueposrate(x, truth = truth, fitted = testprobs)})

townleym/mMisc documentation built on May 6, 2019, 10:52 a.m.