Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projpred:::auc() incorrect for binomial family with > 1 trials #329

Closed
fweber144 opened this issue Jul 6, 2022 · 0 comments
Closed

projpred:::auc() incorrect for binomial family with > 1 trials #329

fweber144 opened this issue Jul 6, 2022 · 0 comments

Comments

@fweber144
Copy link
Collaborator

Following upon #328, the following shows that projpred:::auc() gives an incorrect result in case of a binomial family with > 1 trials:

set.seed(6834)
nobs <- 100L
mu <- binomial()$linkinv(-0.42 + rnorm(nobs))
trials <- sample.int(30L, size = nobs, replace = TRUE)
y <- rbinom(nobs, size = trials, prob = mu)
dat <- data.frame(y = y, mu = mu, trials = trials)

( auc_val_projpred <- projpred:::auc(cbind(y, mu, trials)) )
## Gives: 0.4909168
# Convert to augmented (long) format:
dat_long <- do.call(rbind, lapply(seq_len(nobs), function(i_short) {
  data.frame(y = c(rep(0L, trials[i_short] - y[i_short]),
                   rep(1L, y[i_short])),
             mu = mu[i_short])
}))
( auc_val_projpred_long <- projpred:::auc(cbind(dat_long$y, dat_long$mu, 1)) )
## Gives: 0.7301717
library(pROC)
auc_val <- auc(y ~ mu, data = dat_long, direction = "<", algorithm = 1)
( auc_val_pROC <- auc_val[seq_along(auc_val)] ) # Indexing only to drop attributes.
## Gives: 0.7301717
stopifnot(isTRUE(all.equal(auc_val_pROC, auc_val_projpred_long, tolerance = 1e-15)))

The value of 0.4909168 for auc_val_projpred should also be 0.7301717. A possible fix would be to convert the data to long format inside of projpred:::auc(), but perhaps there is a less expensive solution in terms of computational efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant