Add to or replace the roles of variables in a preprocessing recipe.
role_binom(recipe, x, size)role_case(recipe, stratum, weight, replace = FALSE)
role_pred(recipe, offset, replace = FALSE)
role_surv(recipe, time, event)
existing recipe object.
number of counts and trials for the specification of a
BinomialVariate
outcome.
variable for stratified resampling of cases.
numeric variable of case weights for model fitting.
logical indicating whether to replace existing roles.
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.
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.
An updated recipe object.
# NOT RUN {
library(MASS)
library(recipes)
rec <- recipe(time + status ~ sex + age + year + thickness + ulcer,
data = within(Melanoma, status <- status != 2)) %>%
role_surv(time = time, event = status) %>%
role_case(stratum = status)
(res <- resample(rec, model = CoxModel))
summary(res)
# }
Run the code above in your browser using DataLab