Skip to content

Commit 306ba82

Browse files
authored
#6: addressing shift in PPV by one row (#7)
Address #6. Since it was chosen by design to assess `score > x` for each `x in score`, I don't think we can naturally end up with a PPV at prevalence. Other option would be to inflate the resulting dataset manually for this boundary value, but than we would need to artificially add one more score and one more percentile to match the number of rows in the resulting data frame.
2 parents e868e23 + 2b0ece7 commit 306ba82

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)