powered by
fit.model_spec() takes a nested model specification and fits the inner model specification to each nested data frame in the given dataset.
fit.model_spec()
# S3 method for nested_model fit( object, formula, data, case_weights = NULL, control = parsnip::control_parsnip(), ... )
A nested_model_fit object with several elements:
nested_model_fit
spec: The model specification object (the inner model of the nested model object)
spec
fit: A tibble containing the model fits and the nests that they correspond to.
fit
inner_names: A character vector of names, used to help with nesting the data during predictions.
inner_names
An nested_model object (see nested()).
nested_model
nested()
An object of class formula. Passed into parsnip::fit.model_spec(). This should not contain the variable to nest by.
formula
parsnip::fit.model_spec()
A data frame. If used with a 'nested_model' object, the data frame must already be nested.
An optional vector of case weights. Passed into parsnip::fit.model_spec().
A parsnip::control_parsnip() object. Passed into parsnip::fit.model_spec().
parsnip::control_parsnip()
Passed into parsnip::fit.model_spec(). Currently unused.
parsnip::fit.model_spec() parsnip::model_fit
library(parsnip) library(tidyr) model <- linear_reg() %>% set_engine("lm") %>% nested() nested_data <- nest(example_nested_data, data = -id) fit(model, z ~ x + y + a + b, nested_data)
Run the code above in your browser using DataLab