Fits a list of trending_model objects to the given input data.
Usage
# S3 method for list
fit(x, data, ...)
Arguments
- x
A list of trending_model objects
- data
A data frame containing the data to fit.
- ...
Not currently used.
Value
A trending_fit_tbl
object which is a tibble
subclass with one row for each model and entries:
model_name (optional): If the input is a named list then the name is extracted.
result: the resulting fit from calling the underlying model directly, i.e.
lm_model
: a fitted model object of classlm
glm_model
: a fitted model object of classglm
glm_nb_model
: a fitted model object of classnegbin
brm_model
: An object of classbrmsfit
NULL
if fitting fails.warnings: any warnings generated during fitting
errors: any errors generated during fitting
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(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]>