1- # gen_additive_mod() - General Interface to Linear GAM Models
2- # - backend: gam
3- # - prediction:
4- # - mode = "regression" (default) uses
5- # - mode = "classification"
6-
71# ' Generalized additive models (GAMs)
82# '
3+ # ' @description
94# ' `gen_additive_mod()` defines a model that can use smoothed functions of
105# ' numeric predictors in a generalized linear model.
116# '
127# ' There are different ways to fit this model. See the engine-specific pages
138# ' for more details
149# '
15- # ' More information on how `parsnip` is used for modeling is at
16- # ' \url{https://www.tidymodels.org}.
17- # '
18- # ' @inheritParams boost_tree
19- # ' @param select_features TRUE or FALSE. If this is TRUE then can add an
20- # ' extra penalty to each term so that it can be penalized to zero.
21- # ' This means that the smoothing parameter estimation that is part of
22- # ' fitting can completely remove terms from the model. If the corresponding
23- # ' smoothing parameter is estimated as zero then the extra penalty has no effect.
24- # ' Use `adjust_deg_free` to increase level of penalization.
25- # ' @param adjust_deg_free If `select_features = TRUE`, then acts as a multiplier for smoothness.
26- # ' Increase this beyond 1 to produce smoother models.
27- # '
28- # '
29- # ' @return
30- # ' A `parsnip` model specification
31- # '
32- # ' @details
33- # '
34- # ' This function only defines what _type_ of model is being fit. Once an engine
35- # ' is specified, the _method_ to fit the model is also defined.
36- # '
37- # ' The model is not trained or fit until the [fit.model_spec()] function is used
38- # ' with the data.
10+ # ' \Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("gen_additive_mod")}
3911# '
40- # ' __gam__
12+ # ' More information on how \pkg{parsnip} is used for modeling is at
13+ # ' \url{https://www.tidymodels.org/}.
4114# '
42- # ' This engine uses [mgcv::gam()] and has the following parameters,
43- # ' which can be modified through the [set_engine()] function.
44- # '
45- # ' ``` {r echo=F}
46- # ' str(mgcv::gam)
47- # ' ```
48- # '
49- # ' @section Fit Details:
50- # '
51- # ' __MGCV Formula Interface__
52- # '
53- # ' Fitting GAMs is accomplished using parameters including:
15+ # ' @inheritParams boost_tree
16+ # ' @param select_features `TRUE` or `FALSE.` If `TRUE`, the model has the
17+ # ' ability to eliminate a predictor (via penalization). Increasing
18+ # ' `adjust_deg_free` will increase the likelihood of removing predictors.
19+ # ' @param adjust_deg_free If `select_features = TRUE`, then acts as a multiplier
20+ # ' for smoothness. Increase this beyond 1 to produce smoother models.
5421# '
55- # ' - [mgcv::s()]: GAM spline smooths
56- # ' - [mgcv::te()]: GAM tensor product smooths
22+ # ' @template spec-details
5723# '
58- # ' These are applied in the `fit()` function:
24+ # ' @template spec-references
5925# '
60- # ' ``` r
61- # ' fit(value ~ s(date_mon, k = 12) + s(date_num), data = df)
62- # ' ```
26+ # ' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("gen_additive_mod")}
6327# '
64- # ' @references \url{https://www.tidymodels.org},
65- # ' [_Tidy Models with R_](https://tmwr.org)
6628# ' @examples
29+ # ' show_engines("gen_additive_mod")
6730# '
68- # ' #show_engines("gen_additive_mod")
69- # '
70- # ' #gen_additive_mod()
71- # '
31+ # ' gen_additive_mod()
7232# '
7333# ' @export
7434gen_additive_mod <- function (mode = " unknown" ,
7535 select_features = NULL ,
76- adjust_deg_free = NULL ) {
36+ adjust_deg_free = NULL ,
37+ engine = " mgcv" ) {
7738
7839 args <- list (
7940 select_features = rlang :: enquo(select_features ),
@@ -86,7 +47,7 @@ gen_additive_mod <- function(mode = "unknown",
8647 eng_args = NULL ,
8748 mode = mode ,
8849 method = NULL ,
89- engine = NULL
50+ engine = engine
9051 )
9152
9253}
0 commit comments