fit()
is a generic to fit a specified model.
Arguments
- x
An R object
- data
A data frame containing the data to fit.
- ...
Arguments passed to underlying methods.
Examples
x = rnorm(100, mean = 0)
y = rpois(n = 100, lambda = exp(1.5 + 0.5*x))
dat <- data.frame(x = x, y = y)
poisson_model <- glm_model(y ~ x , family = poisson)
negbin_model <- glm_nb_model(y ~ x)
fit(poisson_model, dat)
#> <trending_fit_tbl> 1 x 3
#> result warnings errors
#> <list> <list> <list>
#> 1 <glm> <NULL> <NULL>
fit(negbin_model, dat)
#> <trending_fit_tbl> 1 x 3
#> result warnings errors
#> <list> <list> <list>
#> 1 <negbin> <NULL> <NULL>
fit(list(poisson_model, negbin_model), dat)
#> <trending_fit_tbl> 2 x 3
#> result warnings errors
#> <list> <list> <list>
#> 1 <NULL> <NULL> <chr [1]>
#> 2 <NULL> <NULL> <chr [1]>
fit(list(pm = poisson_model, nm = negbin_model), dat)
#> <trending_fit_tbl> 2 x 4
#> model_name result warnings errors
#> <chr> <named list> <named list> <named list>
#> 1 pm <NULL> <NULL> <chr [1]>
#> 2 nm <NULL> <NULL> <chr [1]>