step_nls
step_nls.Rd
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 theavmax
parameter incontrol
, settingavmax
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
. IfTRUE
, 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
See also
Other ols:
step_ols()
Examples
data("kennel_2020")
kennel_2020[, datetime := as.numeric(datetime)]
#> datetime baro wl et
#> <num> <num> <num> <num>
#> 1: 1471478400 9.450323 13.31938 269.3297
#> 2: 1471478460 9.449909 13.31864 276.6653
#> 3: 1471478520 9.450103 13.31875 283.9697
#> 4: 1471478580 9.450135 13.31891 291.2427
#> 5: 1471478640 9.450521 13.31888 298.4836
#> ---
#> 81357: 1476359760 9.498389 13.18380 685.3137
#> 81358: 1476359820 9.498701 13.18382 685.0776
#> 81359: 1476359880 9.498266 13.18339 684.7894
#> 81360: 1476359940 9.498545 13.18312 684.4491
#> 81361: 1476360000 9.498260 13.18315 684.0567
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()