f_binomial_glm: Area Under the Curve of Binomial GLM predictions vs....

View source: R/f_binomial_glm.R

f_binomial_glmR Documentation

Area Under the Curve of Binomial GLM predictions vs. observations

Description

Fits a Quasibinomial GLM model y ~ x with the binomial response y (values 0 and 1) and the numeric, character, or factor predictor x using stats::glm() and returns the area under the ROC curve of the observations against the predictions (see score_auc()).

Cases are weighted with case_weights() to prevent issues arising from class imbalance.

Supports cross-validation via the arguments arguments cv_training_fraction (numeric between 0 and 1) and cv_iterations (integer between 1 and n) introduced via ellipsis (...). See preference_order() for further details.

Usage

f_binomial_glm(df, ...)

Arguments

df

(required, dataframe) with columns:

  • "x": (numeric, character, factor) predictor.

  • "y" (integer) binomial response with unique values 0 and 1.

...

(optional) Accepts the arguments cv_training_fraction (numeric between 0 and 1) and cv_iterations (integer between 1 and Inf) for cross validation.

Value

numeric or numeric vector: AUC

See Also

Other preference_order_functions: f_binomial_gam(), f_binomial_rf(), f_categorical_rf(), f_count_gam(), f_count_glm(), f_count_rf(), f_numeric_gam(), f_numeric_glm(), f_numeric_rf(), preference_order()

Examples

data(vi_smol)

df <- data.frame(
  y = vi_smol[["vi_binomial"]],
  x = vi_smol[["swi_max"]]
)

#no cross-validation
f_binomial_glm(df = df)

#cross-validation
f_binomial_glm(
  df = df,
  cv_training_fraction = 0.5,
  cv_iterations = 10
  )

#categorical predictor
df <- data.frame(
  y = vi_smol[["vi_binomial"]],
  x = vi_smol[["koppen_zone"]]
)

f_binomial_glm(df = df)

collinear documentation built on Dec. 8, 2025, 5:06 p.m.