smooth_formula_string {autogam}R Documentation

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:

Usage

smooth_formula_string(
  data,
  y_col,
  smooth_fun = "s",
  bs = "cr",
  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.

bs

See documentation for autogam()

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')


[Package autogam version 0.1.0 Index]