tidy.nested_model_fit {nestedmodels}R Documentation

Turn a nested model into a tidy tibble

Description

Use broom functions on fitted nested models.

tidy.nested_model_fit() summarises components of each model within a nested model fit, indicating which nested data frame each row corresponds to.

glance.nested_model_fit() summarises a nested model, returning a tibble::tibble() with 1 row.

glance_nested() summarises each model within a nested model fit, returning a tibble::tibble() with the same number of rows as the number of inner models.

Usage

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

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

glance_nested(x, ...)

Arguments

x

A nested_model_fit object produced by fit.nested_model().

...

Additional arguments passed into their respective functions. (e.g. for tidy.nested_model_fit(), parsnip::tidy.model_fit()).

Details

generics::glance() states that glance() methods should always return 1 row outputs for non-empty inputs. The 'nestedmodels' package is no exception: glance() methods will combine rows to produce a result with a single row. Specifically:

Value

A tibble::tibble(). With glance.nested_model_fit(), the tibble will have 1 row.

See Also

generics::tidy() generics::glance()

Examples



library(dplyr)
library(parsnip)
library(broom)

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

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

fit <- fit(
  model, z ~ x + y + a + b,
  group_by(data, id)
)

tidy(fit)
glance(fit)
glance_nested(fit)


[Package nestedmodels version 1.1.0 Index]