Learn R Programming

swash (version 1.3.2)

binary_metrics: Fit metrics of observed and expected binary variables

Description

Calculation of fit metrices for binary variables (Sensitivity, specificity, accuracy)

Usage

binary_metrics(
  observed, 
  expected,
  no_information_rate = "negative"
  )

Value

list with two entries:

fit_metrics:

list with fit metrics (sens, spec, ...)

observed_expected:

data.frame with observed, expected and hit (1/0)

Arguments

observed

Numeric vector: Y observed

expected

Numeric vector: Y expected

no_information_rate

bool argument which indicates whether the no-information rate is calculated based on negatives or positives

Author

Thomas Wieland

Details

The function computes model performance metrices for binary outcomes. Observed and expected data must be stated by the user. The function returns sensitivity, specificity, accurracy, and no-information rate.

References

Altman DG, Bland JM (1994) Diagnostic tests. 1: Sensitivity and specificity. British Medical Journal 308, 1552. tools:::Rd_expr_doi("https://doi.org/10.1136/bmj.308.6943.1552").

Boehmke B, Greenwell B (2020) Hands-On Machine Learning with R (1 ed.). Taylor & Francis, New York, NY.

See Also

metrics, binary_metrics_glm

Examples

Run this code
obs <- c(1,1,0,0,0,0,1,0,1)
exp <- c(0,1,0,0,0,0,1,0,0)

binary_metrics(
  obs,
  exp
)

Run the code above in your browser using DataLab