step_robust_gandh: Robust Tukey g-and-h Transformation Recipe Step

View source: R/recipe_steps_robust_gandh.R

step_robust_gandhR Documentation

Robust Tukey g-and-h Transformation Recipe Step

Description

Creates a recipe step applying robust_gandh() to the selected variables. The rQLS fit and all standardization constants are estimated during prep() on the training data and applied unchanged during bake().

Usage

step_robust_gandh(
  recipe,
  ...,
  role = NA,
  trained = FALSE,
  n_quantiles = 10,
  cutoff = NULL,
  max_iter = 50,
  tol = 1e-06,
  standardize = TRUE,
  res = NULL,
  columns = NULL,
  skip = FALSE,
  id = recipes::rand_id("robust_gandh")
)

Arguments

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 recipes::selections().

role

Not used by this step, since no new variables are created.

trained

A logical indicating whether the step has been trained.

n_quantiles

Number of fitting quantiles, an integer from 4 to 20. Default is 10, as recommended for rQLS in the paper.

cutoff

Positive, finite Tukey biweight cutoff on the median/MAD standardized input scale. NULL (default) selects it adaptively for each variable. It is an order-statistic fitting tolerance, not a normal score cutoff or a contamination percentage.

max_iter

Maximum number of trimming/refitting iterations per cutoff. Default is 50.

tol

Positive, finite relative tolerance for convergence. Default is 1e-6.

standardize

A logical value: standardize the transformed variables by the mean and standard deviation of the inliers (TRUE, default).

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 recipes::bake()? Keep the default FALSE, so that new data are corrected with the same filter as the training data.

id

A character string that is unique to this step.

Details

Selected columns are replaced in place. Missing values stay missing and variables without enough observations or spread are left unchanged, as in robust_gandh(). tidy() returns terms, location, scale, g, h and id; location and scale are on the original input scale.

Value

An updated version of recipe with the new step added to the sequence of existing steps.

Author(s)

Christian L. Goueguel

See Also

robust_gandh(), step_robust_boxcox(), step_robust_yeojohnson()

Examples


data(forageLIBS)
contents <- forageLIBS[c("Ca", "K", "P", "Mn")]
rec <- recipes::recipe(~ ., data = contents[1:300, ]) |>
  step_robust_gandh(recipes::all_numeric_predictors())
trained <- recipes::prep(rec)
recipes::bake(trained, new_data = contents[301:368, ])


specProc documentation built on Nov. 20, 2026, 5:11 p.m.