Learn R Programming

cutpointr (version 1.0.2)

metric_constrain: Metrics that are constrained by another metric

Description

For example, calculate sensitivity where a lower bound (minimal desired value) for specificty can be defined. All returned metric values for cutpoints that lead to values of the constraining metric below the specified minimum will be zero. The inputs must be vectors of equal length.

Usage

metric_constrain(
  tp,
  fp,
  tn,
  fn,
  main_metric = sensitivity,
  constrain_metric = specificity,
  min_constrain = 0.5,
  suffix = "_constrain",
  ...
)

sens_constrain( tp, fp, tn, fn, constrain_metric = specificity, min_constrain = 0.5, ... )

spec_constrain( tp, fp, tn, fn, constrain_metric = sensitivity, min_constrain = 0.5, ... )

acc_constrain( tp, fp, tn, fn, constrain_metric = sensitivity, min_constrain = 0.5, ... )

Arguments

tp

(numeric) number of true positives.

fp

(numeric) number of false positives.

tn

(numeric) number of true negatives.

fn

(numeric) number of false negatives.

main_metric

Metric to be optimized.

constrain_metric

Metric for constraint.

min_constrain

Minimum desired value of constrain_metric.

suffix

Character string to be added to the name of main_metric.

...

for capturing additional arguments passed by method.

See Also

Other metric functions: F1_score(), Jaccard(), abs_d_ppv_npv(), abs_d_sens_spec(), accuracy(), cohens_kappa(), cutpoint(), false_omission_rate(), misclassification_cost(), npv(), odds_ratio(), p_chisquared(), plr(), ppv(), precision(), prod_ppv_npv(), prod_sens_spec(), recall(), risk_ratio(), roc01(), sensitivity(), specificity(), sum_ppv_npv(), sum_sens_spec(), total_utility(), tpr(), tp(), youden()

Examples

Run this code
# NOT RUN {
## Maximum sensitivity when specificity is at least 95%
cp <- cutpointr(suicide, dsi, suicide,
  metric = sens_constrain, constrain_metric = ppv, min_constrain = 0.75)
plot_metric(cp)
# }

Run the code above in your browser using DataLab