dx_npv_prevalence | R Documentation |
Computes the Negative Predictive Value (NPV) adjusted to a specified prevalence level. This function is useful for understanding classifier performance in settings where the actual prevalence of the condition may differ from that in the initial data.
dx_npv_prevalence(cm, prevalence, detail = "full", ...)
cm |
A dx_cm object created by |
prevalence |
Numeric value between 0 and 1, representing the target prevalence for adjusting the NPV calculation. |
detail |
Character specifying the level of detail in the output: "simple" for raw estimate, "full" for detailed estimate including 95% confidence intervals. |
... |
Additional arguments to pass to metric_binomial function, such as
|
This function calculates the NPV using the formula:
NPV = \frac{Specificity \times (1 - Prevalence)}{(1 - Sensitivity) \times Prevalence + Specificity \times (1 - Prevalence)}
where Specificity
is the true negative rate and Sensitivity
is the true positive rate.
Adjusting NPV for prevalence allows better estimation of the classifier’s performance
in different population settings.
Confidence intervales are calucated using a simple logit (Mercaldo et al, 2007)
Depending on the detail
parameter, returns a numeric value
representing the calculated metric or a data frame/tibble with
detailed diagnostics including confidence intervals and possibly other
metrics relevant to understanding the metric.
dx_cm()
, dx_npv()
for the non-prevalence adjusted NPV.
cm <- dx_cm(dx_heart_failure$predicted, dx_heart_failure$truth,
threshold = 0.5, poslabel = 1
)
# Calculate NPV at a prevalence of 0.1
dx_npv_prevalence(cm, prevalence = 0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.