augment.nested_model_fit {nestedmodels}R Documentation

Augment data with predictions

Description

generics::augment() method for nested models. augment.nested_model_fit() will add column(s) for predictions to the given data.

Usage

## S3 method for class 'nested_model_fit'
augment(x, new_data, ...)

Arguments

x

A nested_model_fit object produced by fit.nested_model().

new_data

A data frame - can be nested or non-nested.

...

Passed onto parsnip::augment.model_fit().

Value

A data frame with one or more added columns for predictions.

See Also

parsnip::augment.model_fit()

Examples


library(dplyr)
library(tidyr)
library(parsnip)

data <- filter(example_nested_data, id %in% 1:5)

nested_data <- nest(data, data = -c(id, id2))

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

fitted <- fit(model, z ~ x + y + a + b, nested_data)

augment(fitted, example_nested_data)


[Package nestedmodels version 1.1.0 Index]