Learn R Programming

nestedmodels (version 1.1.0)

augment.nested_model_fit: 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 nested_model_fit
augment(x, new_data, ...)

Value

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

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().

See Also

Examples

Run this code

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)

Run the code above in your browser using DataLab