internalGetMetrics: Calculate overall performance metrics

View source: R/nbc4va_internal.R

internalGetMetricsR Documentation

Calculate overall performance metrics

Description

A vector providing overall performance metrics based on input predicted and observed cases.

Usage

internalGetMetrics(
  pred,
  obs,
  causes = unique(c(pred, obs)),
  csmfa.obs = NULL,
  causeMetrics = internalGetCauseMetrics(pred, obs, causes)
)

Arguments

pred

Chracter vector of predicted causes for each case.

obs

Character vector of observed causes for each case.

causes

Character vector of all possible causes including ones that are not in the pred or obs.

csmfa.obs

A character vector of the true causes for calculating the CSMF accuracy.

causeMetrics

Dataframe of a performance metrics per cause (see internalGetCauseMetrics):

  • Columns: Cause, TruePositives, TrueNegatives, FalsePositives, FalseNegatives, PredictedFrequency, ObservedFrequency, Sensitivity, CSMFpredicted, CSMFobserved

  • Cause (vectorof char): The unique causes from both the obs and pred inputs

  • TruePositives (vectorof double): The total number of true positives per cause

  • TrueNegatives (vectorof double): The total number of true negatives per cause

  • FalsePositives (vectorof double): The total number of false positives per cause

  • FalseNegatives (vectorof double): The total number of false negatives per cause

  • PredictedFrequency (vectorof double): The occurence of a cause in the pred input

  • ObservedFrequency (vectorof double): The occurence of a cause in the obs input

  • Sensitivity (vectorof double): the sensitivity for a cause

  • CSMFpredicted (vectorof double): the cause specific mortality fraction for a cause given the predicted deaths

  • CSMFobserved (vectorof double): the cause specific mortality fraction for a cause given the observed deaths

Details

Developer Note: Depends on the internalGetCSMFAcc function to get the CSMF Accuracy.

Value

metrics Named numeric vector of performance metrics (see Methods documentation):

  • Names: TruePositives, TrueNegatives, FalsePositives, FalseNegatives, Accuracy, Sensitivity, Specificity, PCCC, CSMFMaxError, CSMFaccuracy

  • TruePositives (double): total number of true positives

  • TrueNegatives (double): total number of true negatives

  • FalsePositives (double): total number of false positives

  • FalseNegatives (double): total number of false negatives

  • Sensitivity (double): the overall sensitivity

  • PCCC (double): the partial chance corrected concordance

  • CSMFMaxError (double): the maximum Cause Specific Mortality Fraction Error

  • CSMFaccuracy (double): the Cause Specific Mortaliy Fraction accuracy

See Also

Other internal functions: internalGetCSMFAcc(), internalGetCSMFMaxError(), internalGetCauseMetrics(), internalNBC()

Examples

library(nbc4va)
pred <- c("HIV", "Stroke", "HIV", "Stroke")
obs <- c("HIV", "HIV", "Stroke", "Stroke")
metrics <- nbc4va::internalGetMetrics(pred, obs)


nbc4va documentation built on May 10, 2022, 5:07 p.m.