step_nls: step_nls

View source: R/api_recipes.R

step_nlsR Documentation

step_nls

Description

Uses the Eigen C++ library fast versions to generate predictions and coefficients from a recipe.

Usage

step_nls(
  .rec,
  formula,
  algorithm = "lm",
  n_subset = 1L,
  n_shift = 0L,
  range = c(-Inf, Inf),
  control = gsl_nls_control(xtol = 1e-08),
  trace = FALSE,
  role = "predictor",
  ...
)

Arguments

.rec

the R6 recipe object.

formula

formula for the regression

algorithm

character string specifying the algorithm to use. The following choices are supported:

  • "lm" Levenberg-Marquardt algorithm (default).

  • "lmaccel" Levenberg-Marquardt algorithm with geodesic acceleration. Stability is controlled by the avmax parameter in control, setting avmax to zero is analogous to not using geodesic acceleration.

  • "dogleg" Powell's dogleg algorithm.

  • "ddogleg" Double dogleg algorithm, an improvement over "dogleg" by including information about the Gauss-Newton step while the iteration is still far from the minimum.

  • "subspace2D" 2D generalization of the dogleg algorithm. This method searches a larger subspace for a solution, it can converge more quickly than "dogleg" on some problems.

n_subset

integer - spacing between adjacent samples in the result.

n_shift

integer - number of values to shift the starting position when n_subset is not equal to 0. The value of n_shift has to be less than 'n_subset'.

range

limit the fitting range to observations between range[1] and range[2]

control

an optional list of control parameters to tune the least squares iterations and multistart algorithm. See gsl_nls_control for the available control parameters and their default values.

trace

logical value indicating if a trace of the iteration progress should be printed. Default is FALSE. If TRUE, the residual (weighted) sum-of-squares and the current parameter estimates are printed after each iteration.

role

character - the name of the role

...

additional arguments

Value

an updated recipe

See Also

Other ols: step_ols()

Examples

data("kennel_2020")
kennel_2020[, datetime := as.numeric(datetime)]
formula <- as.formula(wl~.)
n_knots <- 12
deg_free <- 27
max_lag <- 1 + 720

frec = recipe(formula = formula, data = unclass(kennel_2020)) |>
  step_distributed_lag(baro, knots = hydrorecipes:::log_lags_arma(n_knots, max_lag)) |>
  step_spline_b(datetime, df = deg_free, intercept = FALSE) |>
  step_intercept() |>
  step_drop_columns(baro) |>
  step_drop_columns(datetime) |>
  step_ols(formula) |>
  prep() |>
  bake()

jkennel/hydrorecipes documentation built on Feb. 23, 2025, 11:03 a.m.