| 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] (ORCID: <https://orcid.org/0000-0001-5574-7572>) |
| Maintainer: | Chitu Okoli <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-06 05:38:01 UTC |
| Source: | https://github.com/tripartio/autogam |
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.
autogam(data, y_col, ..., bs = "cr")autogam(data, y_col, ..., bs = "cr")
data |
dataframe. All the variables in |
y_col |
character(1). Name of the y outcome variable. |
... |
Arguments passed on to |
bs |
character(1). The default basis function for GAM smooths. See |
Returns an mgcv::gam object, the result of predicting y_col from all other variables in data.
autogam(mtcars, 'mpg')autogam(mtcars, 'mpg')
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().
## S3 method for class 'autogam' anova(object, ...) ## S3 method for class 'autogam' coef(object, ...) ## 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(object, ...) ## S3 method for class 'autogam' model.matrix(object, ...) ## S3 method for class 'autogam' predict(object, ...) ## S3 method for class 'autogam' residuals(object, ...) ## S3 method for class 'autogam' vcov(object, ...)## S3 method for class 'autogam' anova(object, ...) ## S3 method for class 'autogam' coef(object, ...) ## 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(object, ...) ## S3 method for class 'autogam' model.matrix(object, ...) ## S3 method for class 'autogam' predict(object, ...) ## S3 method for class 'autogam' residuals(object, ...) ## S3 method for class 'autogam' vcov(object, ...)
object, model
|
An object of class |
... |
other arguments |
x |
formula |
Returns the return object of the corresponding mgcv::gam method.
This function plots an autogam object. It calls the mgcv::gam object mgcv::plot.gam() method.
## S3 method for class 'autogam' plot(x, ...)## S3 method for class 'autogam' plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to other methods. |
Same return object as mgcv::print.gam().
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.
## S3 method for class 'autogam' print(x, ...)## S3 method for class 'autogam' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to other methods. |
Invisibly returns the input object x.
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.
smooth_formula_string( data, y_col, smooth_fun = "s", bs = "cr", expand_parametric = TRUE )smooth_formula_string( data, y_col, smooth_fun = "s", bs = "cr", expand_parametric = TRUE )
data |
dataframe. All the variables in |
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 |
bs |
See documentation for |
expand_parametric |
logical(1). If |
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.
smooth_formula_string(mtcars, 'mpg')smooth_formula_string(mtcars, 'mpg')
This function returns a summary of an autogam object. It calls the mgcv::gam object mgcv::summary.gam() method.
## S3 method for class 'autogam' summary(object, ...)## S3 method for class 'autogam' summary(object, ...)
object |
An object of class |
... |
Additional arguments passed to other methods. |
Same return object as mgcv::summary.gam().