Skip to contents

step_measure_baseline_minima() creates a specification of a recipe step that estimates baseline by interpolating between local minima.

Usage

step_measure_baseline_minima(
  recipe,
  measures = NULL,
  window_size = 50L,
  method = c("spline", "linear"),
  role = NA,
  trained = FALSE,
  skip = FALSE,
  id = recipes::rand_id("measure_baseline_minima")
)

Arguments

recipe

A recipe object.

measures

An optional character vector of measure column names.

window_size

Window size for finding local minima. Default is 50.

method

Interpolation method: "linear" or "spline". Default is "spline".

role

Not used.

trained

Logical indicating if the step has been trained.

skip

Logical. Should the step be skipped when baking?

id

Unique step identifier.

Value

An updated recipe with the new step added.

Details

This method finds local minima within specified windows, then interpolates between them to create a baseline estimate. This is intuitive and works well when baseline points are clearly identifiable as local minima.

Examples

library(recipes)

rec <- recipe(water + fat + protein ~ ., data = meats_long) |>
  update_role(id, new_role = "id") |>
  step_measure_input_long(transmittance, location = vars(channel)) |>
  step_measure_baseline_minima(window_size = 30, method = "spline") |>
  prep()