Skip to content

Commit

Permalink
#6: addressing shift in PPV by one row
Browse files Browse the repository at this point in the history
  • Loading branch information
slamao committed Feb 14, 2025
1 parent e868e23 commit 2b0ece7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/PV.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ nonParametricPV <- function(outcome, score) {
thresh.predictions <- lapply(score, function(x) as.numeric(score > x))

ppv <- vapply(
thresh.predictions[1:(length(score) - 1)],
thresh.predictions,
function(x) {
yardstick::ppv_vec(
truth = factor(outcome, levels = c("1", "0")),
Expand All @@ -44,7 +44,7 @@ nonParametricPV <- function(outcome, score) {
)

npv <- vapply(
thresh.predictions[1:(length(score) - 1)],
thresh.predictions,
function(x) {
yardstick::npv_vec(
truth = factor(outcome, levels = c("1", "0")),
Expand All @@ -58,8 +58,8 @@ nonParametricPV <- function(outcome, score) {
threshold.data <- data.frame(
score = score,
percentile = ecdf(score)(score),
PPV = c(prev, ppv),
NPV = c(npv, 1 - prev)
PPV = ppv,
NPV = npv
) %>%
mutate(MNPV = 1 - .data$NPV) %>%
tidyr::fill(
Expand Down

0 comments on commit 2b0ece7

Please sign in to comment.