Skip to content

Commit 2b0ece7

Browse files
committed
#6: addressing shift in PPV by one row
1 parent e868e23 commit 2b0ece7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/PV.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ nonParametricPV <- function(outcome, score) {
3232
thresh.predictions <- lapply(score, function(x) as.numeric(score > x))
3333

3434
ppv <- vapply(
35-
thresh.predictions[1:(length(score) - 1)],
35+
thresh.predictions,
3636
function(x) {
3737
yardstick::ppv_vec(
3838
truth = factor(outcome, levels = c("1", "0")),
@@ -44,7 +44,7 @@ nonParametricPV <- function(outcome, score) {
4444
)
4545

4646
npv <- vapply(
47-
thresh.predictions[1:(length(score) - 1)],
47+
thresh.predictions,
4848
function(x) {
4949
yardstick::npv_vec(
5050
truth = factor(outcome, levels = c("1", "0")),
@@ -58,8 +58,8 @@ nonParametricPV <- function(outcome, score) {
5858
threshold.data <- data.frame(
5959
score = score,
6060
percentile = ecdf(score)(score),
61-
PPV = c(prev, ppv),
62-
NPV = c(npv, 1 - prev)
61+
PPV = ppv,
62+
NPV = npv
6363
) %>%
6464
mutate(MNPV = 1 - .data$NPV) %>%
6565
tidyr::fill(

0 commit comments

Comments
 (0)