Fit and predict in a single function.

fit_model(
  df = NULL,
  yname = NULL,
  xname = NULL,
  modeltype = NULL,
  drop_non_numeric = FALSE,
  ...
)

Arguments

df

A data.frame object

yname

The outcome variable

xname

The predictor variable(s)

modeltype

A character specifying the model type e.g lm for linear model

drop_non_numeric

Should non numeric columns be dropped? Defaults to FALSE

...

Other arguments to specific model types.

Examples

data("yields", package="manymodelr")
fit_model(yields,"height","weight","lm")
#> 
#> Call:
#> lm(formula = height ~ weight, data = use_df)
#> 
#> Coefficients:
#> (Intercept)       weight  
#>      0.5661      -0.2174  
#> 
fit_model(yields, "weight","height + I(yield)**2","lm")
#> 
#> Call:
#> lm(formula = weight ~ height + I(yield)^2, data = use_df)
#> 
#> Coefficients:
#> (Intercept)       height     I(yield)  
#>   0.0112753   -0.1463926    0.0006827  
#>