Skip to content

Commit

Permalink
Revert "oravght shortcut"
Browse files Browse the repository at this point in the history
This reverts commit 253cd10.
  • Loading branch information
vincentarelbundock committed Oct 17, 2023
1 parent 56bf4ea commit b5c1674
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
4 changes: 1 addition & 3 deletions R/comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ comparisons <- function(model,
# required by stubcols later, but might be overwritten
bycols <- NULL

# before sanitize_newdata
sanity_comparison(comparison, wts, newdata)

# sanity checks
sanity_dots(model, ...)
sanity_df(df, newdata)
Expand All @@ -318,6 +315,7 @@ comparisons <- function(model,
...)
cross <- sanitize_cross(cross, variables, model)
type <- sanitize_type(model = model, type = type, calling_function = "comparisons")
sanity_comparison(comparison)
tmp <- sanitize_hypothesis(hypothesis, ...)
hypothesis <- tmp$hypothesis
hypothesis_null <- tmp$hypothesis_null
Expand Down
14 changes: 1 addition & 13 deletions R/sanitize_comparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ comparison_function_dict <- list(
"lnoravg" = function(hi, lo) log((mean(hi) / (1 - mean(hi))) / (mean(lo) / (1 - mean(lo)))),
"lnoravgwts" = function(hi, lo, w) log((wmean(hi, w) / (1 - wmean(hi, w))) / (wmean(lo, w) / (1 - wmean(lo, w)))),

"oravght" = function(hi, lo, w, newdata) {
mu_lo <- sum(lo * w) / nrow(newdata)
mu_hi <- sum(hi * w) / nrow(newdata)
(mu_hi / (1 - mu_hi)) / (mu_lo / (1 - mu_lo))
},

# others
"lift" = function(hi, lo) (hi - lo) / lo,
"liftavg" = function(hi, lo) (mean(hi) - mean(lo)) / mean(lo),
Expand Down Expand Up @@ -88,19 +82,13 @@ comparison_label_dict <- list(
"lnoravg" = "ln(odds(%s) / odds(%s))",
"lnoravgwts" = "ln(odds(%s) / odds(%s))",

"oravght" = "odds(%s) / odds(%s)",

"lift" = "lift",
"liftavg" = "liftavg",

"expdydx" = "exp(dY/dX)"
)

sanity_comparison <- function(comparison, wts = NULL, newdata = NULL) {
if (isTRUE(checkmate::check_choice(comparison, "oravght"))) {
checkmate::assert_false(is.null(wts))
checkmate::assert_false(is.null(newdata))
}
sanity_comparison <- function(comparison) {
# wts versions are used internally but not available directly to users
valid <- names(comparison_function_dict)
valid <- valid[!grepl("wts$", valid)]
Expand Down

0 comments on commit b5c1674

Please sign in to comment.