Skip to content

Bug in AUC.competing.risks with cutpoints #63

@loffleraSMH

Description

@loffleraSMH

Thanks for maintaining this awesome package!

I noticed a small bug in AUC.competing.risks: When running the Score function on a competing risk model, I get the following error when specifying cutpoints:
Error in cutpoint.helper.fun(FPR, TPR, risk, ipcwCases, ipcwControls1, : object 'SE.NPV' not found.

I believe the issue can be resolved by changing line 162 in AUC.competing.risks to NPV <- SE.NPV <- NA.
Similarly, line 141 could be changed to PPV <- SE.PPV <- NA.

The following code replicates the issue:

library(riskRegression)
library(prodlim)
library(survival)

set.seed(123)

# Number of patients
n_patients <- 100

# Generate random patient data
my_data <- data.frame(
  id = 1:n_patients,
  age = sample(18:90, n_patients, replace = TRUE),
  sex = sample(c("Male", "Female"), n_patients, replace = TRUE),
  time = round(runif(n_patients, 30, 1000)),
  status = sample(c(0, 1, 2), n_patients, replace = TRUE, prob = c(0.5, 0.3, 0.2))  # Status: censored, disease, death
)

head(my_data)


model <- riskRegression::FGR(Hist(time, status) ~ age + sex,
                             data = my_data,
                             cause = 1
)

score_result <- Score(
  list(cr_model = model),
  data = my_data,
  formula = Hist(time, status) ~ 1,
  cause = 1,
  times = 365,
  metrics = c("auc", "brier"),
  summary = c("risks", "ipa"),
  plots = c("calibration", "ROC"),
  conf.int = TRUE,
  cutpoints = c(0.05, 0.1)
)

On a related note: Why are PPV and NPV only returned when Score is run with cutpoints input? The reason I ran into this bug was because I'm specifically interested in PPV, which is currently not returned when no cutpoints are provided. Would it be possible to enable PPV (and NPV) without cutpoints input by adding something like this after line 59 of AUC.competing.risks?

aucDT[, PPV := cumsum(ipcwCases) / (cumsum(ipcwCases) + cumsum(ipcwControls1) + cumsum(ipcwControls2))]

Thanks,
Anne

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions