nested {nestedmodels}R Documentation

Create a Nested Model

Description

nested() turns a model or workflow into a nested model/workflow. is_nested() checks if a model or workflow is nested.

Usage

nested(x, ...)

is_nested(x, ...)

## Default S3 method:
nested(x, ...)

## S3 method for class 'model_spec'
nested(x, allow_par = FALSE, pkgs = NULL, ...)

## S3 method for class 'nested_model'
nested(x, allow_par = FALSE, pkgs = NULL, ...)

## S3 method for class 'workflow'
nested(x, allow_par = FALSE, pkgs = NULL, ...)

## Default S3 method:
is_nested(x, ...)

## S3 method for class 'model_spec'
is_nested(x, ...)

## S3 method for class 'workflow'
is_nested(x, ...)

Arguments

x

A model specification or workflow.

...

Not currently used.

allow_par

A logical to allow parallel processing over nests during the fitting process (if a parallel backend is registered).

pkgs

An optional character string of R package names that should be loaded (by namespace) during parallel processing.

Value

A nested model object, or a workflow containing a nested model. For is_nested(), a logical vector of length 1.

Examples



library(parsnip)
library(workflows)

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

model

is_nested(model)

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

is_nested(wf)


[Package nestedmodels version 1.1.0 Index]