Package 'autogam'

Title: Automate the Creation of Generalized Additive Models (GAMs)
Description: This wrapper package for 'mgcv' makes it easier to create high-performing Generalized Additive Models (GAMs). With its central function autogam(), by entering just a dataset and the name of the outcome column as inputs, 'AutoGAM' tries to automate the procedure of configuring a highly accurate GAM which performs at reasonably high speed, even for large datasets.
Authors: Chitu Okoli [aut, cre]
Maintainer: Chitu Okoli <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1.20241004
Built: 2024-11-03 06:07:55 UTC
Source: https://github.com/tripartio/autogam

Help Index


Automate the creation of a Generalized Additive Model (GAM)

Description

autogam() is a wrapper for 'mgcv::gam()' that makes it easier to create high-performing Generalized Additive Models (GAMs). By entering just a dataset and the name of the outcome column as inputs, autogam() tries to automate the procedure of configuring a highly accurate GAM which performs at reasonably high speed, even for large datasets.

Usage

autogam(data, y_col, ...)

Arguments

data

dataframe. All the variables in data will be used to predict y_col. To exclude any variables, assign as data only the subset of variables desired.

y_col

character(1). Name of the y outcome variable.

...

Arguments passed on to mgcv::gam().

Value

Returns an mgcv::gam object, the result of predicting y_col from all other variables in data.

Examples

autogam(mtcars, 'mpg')

Generic autogam methods passed on to mgcv::gam methods

Description

An autogam object contains a gam element that is simply an mgcv::gam object. So, it supports all mgcv::gam methods by, in most cases, simply passing the gam element on to their corresponding mgcv::gam methods. Only the following methods have special specifications for autogam (see their dedicated documentation files for details): print.autogam().

Usage

## S3 method for class 'autogam'
anova(x, ...)

## S3 method for class 'autogam'
coef(x, ...)

## S3 method for class 'autogam'
cooks.distance(model, ...)

## S3 method for class 'autogam'
formula(x, ...)

## S3 method for class 'autogam'
influence(model, ...)

## S3 method for class 'autogam'
logLik(x, ...)

## S3 method for class 'autogam'
model.matrix(x, ...)

## S3 method for class 'autogam'
predict(x, ...)

## S3 method for class 'autogam'
residuals(x, ...)

## S3 method for class 'autogam'
vcov(x, ...)

Arguments

x, model

An object of class autogam.

...

Additional arguments passed to other methods.

Value

Returns the return object of the corresponding mgcv::gam method.


Plot Method for autogam Objects

Description

This function plots an autogam object. It calls the mgcv::gam object mgcv::plot.gam() method.

Usage

## S3 method for class 'autogam'
plot(x, ...)

Arguments

x

An object of class autogam.

...

Additional arguments passed to other methods.

Value

Same return object as mgcv::print.gam().


Print Method for autogam Objects

Description

This function prints an autogam object. It calls the mgcv::gam object print() method and then adds basic performance metrics from the autogam object:

  • For models that predict numeric outcomes, it prints "MAE", the mean absolute error, and "Std. accuracy", the standardized accuracy (staccuracy) of the winsorized MAE relative to the mean absolute deviation.

  • For models that predict binary outcomes, it prints "AUC", the area under the ROC curve.

Usage

## S3 method for class 'autogam'
print(x, ...)

Arguments

x

An object of class autogam.

...

Additional arguments passed to other methods.

Value

Invisibly returns the input object x.


Create a character string for a mgcv::gam formula

Description

Create a character string that wraps appropriate variables in a dataframe with s() smooth functions. Based on the datatype of each variable, it determines whether it is a numeric variable to be smoothed:

  • Non-numeric: no smoothing.

  • Numeric: determine knots based on the number of unique values for that variable:

    • ⁠<= 4⁠: no smoothing

    • ⁠5 to 19⁠ (inclusive): smooth function with knots equal to the floored half of the number of unique values. E.g., 6 unique values receive 3 knots, 7 will receive 3 knots, and 8 will receive 4 knots.

    • ⁠>= 20⁠: smooth function with no specified number of knots, allowing the gam() function to detect the appropriate number.

Usage

smooth_formula_string(data, y_col, smooth_fun = "s", expand_parametric = TRUE)

Arguments

data

dataframe. All the variables in data except y_col will be listed in the resulting formula string. To exclude any variables, assign as data only the subset of variables desired.

y_col

character(1). Name of the y outcome variable.

smooth_fun

character(1). Function to use for smooth wraps; default is 's' for the s() function.

expand_parametric

logical(1). If TRUE (default), explicitly list each non-smooth (parametric) term. If FALSE, use . to lump together all non-smooth terms.

Value

Returns a single character string that represents a formula with y_col on the left and all other variables in data on the right, each formatted with an appropriate s() function when applicable.

Examples

smooth_formula_string(mtcars, 'mpg')

Summary Method for autogam Objects

Description

This function returns a summary of an autogam object. It calls the mgcv::gam object mgcv::summary.gam() method.

Usage

## S3 method for class 'autogam'
summary(object, ...)

Arguments

object

An object of class autogam.

...

Additional arguments passed to other methods.

Value

Same return object as mgcv::summary.gam().