Skip to contents

Fits a binomial logistic Generalized Additive Model (GAM) y ~ s(x, k = 3) between a binary response and a numeric predictor and returns the Area Under the Curve of the observations versus the predictions.

Usage

f_gam_auc_balanced(x, y, df)

Arguments

x

(required, character string) name of the predictor variable.

y

(required, character string) name of the response variable

df

(required, data frame) data frame with the columns 'x' and 'y'.

Value

Area Under the Curve

Examples


data(vi)

#subset to limit example run time
vi <- vi[1:1000, ]

#this example requires "mgcv" installed
if(requireNamespace(package = "mgcv", quietly = TRUE)){

  f_gam_auc_balanced(
    x = "growing_season_length", #predictor
    y = "vi_binary",               #response
    df = vi
  )

}
#> [1] 0.9367964