Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ S3method(as.data.frame,r2_bayes)
S3method(as.data.frame,r2_loo)
S3method(as.data.frame,r2_nakagawa)
S3method(as.numeric,check_outliers)
S3method(as.numeric,performance_roc)
S3method(check_autocorrelation,default)
S3method(check_collinearity,BFBayesFactor)
S3method(check_collinearity,MixMod)
Expand Down
18 changes: 17 additions & 1 deletion R/performance_roc.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#'
#' model <- glm(y ~ Sepal.Length + Sepal.Width, data = train_data, family = "binomial")
#' as.data.frame(performance_roc(model, new_data = test_data))
#' as.numeric(performance_roc(model))
#'
#' roc <- performance_roc(model, new_data = test_data)
#' area_under_curve(roc$Specificity, roc$Sensitivity)
Expand All @@ -66,7 +67,7 @@

object_names <- c(
insight::safe_deparse_symbol(substitute(x)),
sapply(match.call(expand.dots = FALSE)$`...`, insight::safe_deparse)

Check warning on line 70 in R/performance_roc.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/performance_roc.R,line=70,col=44,[keyword_quote_linter] Only quote targets of extraction with $ if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use [[ to extract by string.
)

if (insight::is_model(x)) {
Expand Down Expand Up @@ -122,6 +123,21 @@
}


#' @export
as.numeric.performance_roc <- function(x, ...) {
if (length(unique(x$Model)) == 1) {
auc <- bayestestR::area_under_curve(x$Specificity, x$Sensitivity)
} else {
dat <- split(x, f = x$Model)

auc <- c()

Check warning on line 133 in R/performance_roc.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/performance_roc.R,line=133,col=12,[unnecessary_concatenation_linter] Replace unnecessary c() by NULL or, whenever possible, vector() seeded with the correct type and/or length.
for (i in seq_along(dat)) {
auc <- c(auc, bayestestR::area_under_curve(dat[[i]]$Specificity, dat[[i]]$Sensitivity))
}
}
auc
}


# utilities ---------------------------

Expand Down Expand Up @@ -181,5 +197,5 @@
if (inherits(x, "model_fit")) {
x <- x$fit
}
inherits(x, c("glm", "glmerMod", "logitor", "logitmfx", "probitmfx"))
inherits(x, c("glm", "glmerMod", "logitor", "logitmfx", "probitmfx", "glmmTMB"))
}
1 change: 1 addition & 0 deletions man/performance_roc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading