Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

recipe_roles

Set Recipe Roles


Description

Add to or replace the roles of variables in a preprocessing recipe.

Usage

role_binom(recipe, x, size)

role_case(recipe, stratum, weight, replace = FALSE)

role_pred(recipe, offset, replace = FALSE)

role_surv(recipe, time, event)

Arguments

recipe

existing recipe object.

x, size

number of counts and trials for the specification of a BinomialVariate outcome.

stratum

variable for stratified resampling of cases.

weight

numeric variable of case weights for model fitting.

replace

logical indicating whether to replace existing roles.

offset

numeric variable to be added to a linear predictor, such as in a generalized linear model, with known coefficient 1 rather than an estimated coefficient.

time, event

numeric follow up time and 0-1 numeric or logical event indicator for specification of a Surv outcome. If the event indicator is omitted, all cases are assumed to have events.

Value

An updated recipe object.

See Also

Examples

library(survival)
library(recipes)

rec <- recipe(time + status ~ ., data = veteran) %>%
  role_surv(time = time, event = status) %>%
  role_case(stratum = status)

(res <- resample(rec, model = CoxModel))
summary(res)

MachineShop

Machine Learning Models and Tools

v2.8.0
GPL-3
Authors
Brian J Smith [aut, cre]
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.