fit_xy.nested_model {nestedmodels}R Documentation

Fit a nested model to a dataset using an xy interface.

Description

generics::fit_xy() method for nested models. This should not be called directly and instead should be called by workflows::fit.workflow().

Usage

## S3 method for class 'nested_model'
fit_xy(
  object,
  x,
  y,
  case_weights = NULL,
  control = parsnip::control_parsnip(),
  ...
)

Arguments

object

An nested_model object (see nested()).

x

A data frame of predictors.

y

A data frame of outcome data.

case_weights

An optional vector of case weights. Passed into parsnip::fit.model_spec().

control

A parsnip::control_parsnip() object. Passed into parsnip::fit.model_spec().

...

Passed into parsnip::fit.model_spec(). Currently unused.

Value

A nested_model_fit object with several elements:

See Also

parsnip::fit.model_spec() parsnip::model_fit

Examples



library(dplyr)
library(parsnip)
library(recipes)
library(workflows)

data <- filter(example_nested_data, id %in% 11:20)

model <- linear_reg() %>%
  set_engine("lm") %>%
  nested()

recipe <- recipe(data, z ~ x + y + id) %>%
  step_nest(id)

wf <- workflow() %>%
  add_recipe(recipe) %>%
  add_model(model)

fit(wf, data)


[Package nestedmodels version 1.1.0 Index]