View source: R/recipe_steps_robust.R
| step_robust_boxcox | R Documentation |
step_robust_boxcox() creates a specification of a recipe step that
transforms the selected variables toward central normality with the
robust Box-Cox transformation of robust_boxcox(). It is the robust
counterpart of recipes::step_BoxCox().
step_robust_boxcox(
recipe,
...,
role = NA,
trained = FALSE,
quantile = 0.99,
nbsteps = 2,
standardize = TRUE,
res = NULL,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("robust_boxcox")
)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose the predictors (for
example, the spectral channels). See |
role |
Not used by this step, since no new variables are created. |
trained |
A logical indicating whether the step has been trained. |
quantile |
The quantile of the absolute value of a standard normal variable beyond which the standardized transformed values are given weight zero in the re-weighting steps, strictly between 0 and 1. Default is 0.99. |
nbsteps |
The number of re-weighting steps, a positive integer. Default is 2. |
standardize |
A logical value: standardize the transformed variables
by the mean and standard deviation of the inliers ( |
res |
The fitted transformation, stored once the step has been trained. |
columns |
The names of the selected columns, stored once the step has been trained. |
skip |
A logical. Should the step be skipped when the recipe is baked
by |
id |
A character string that is unique to this step. |
The transformation parameter \lambda of each variable is estimated
on the training data (Raymaekers and Rousseeuw, 2021), as in
robust_boxcox(), and applied unchanged to new data. With
standardize = TRUE, the transformed variables are also centered and
scaled with the mean and standard deviation of the training inliers.
Variables that cannot be transformed (constant ones and, with a warning,
those with zero or negative values) are left unchanged. Missing values are
ignored by the fit and stay missing; new values that are zero or negative
become NA.
tidy() returns a tibble with columns terms,
lambda (NA for the variables left unchanged) and id.
An updated version of recipe with the new step added to the
sequence of existing steps.
Christian L. Goueguel
robust_boxcox(), step_robust_yeojohnson() for variables with
zero or negative values.
library(recipes)
data(forageLIBS)
contents <- forageLIBS[c("Ca", "K", "P", "Mn")]
rec <- recipe(~ ., data = contents[1:300, ]) |>
step_robust_boxcox(all_numeric_predictors())
prepped <- prep(rec)
tidy(prepped, number = 1)
bake(prepped, new_data = contents[301:368, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.