Skip to contents

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

Usage

step_ols(.rec, formula, role = "predictor", do_response = TRUE, ...)

Arguments

.rec

the R6 recipe object.

formula

formula for the regression

role

character - the name of the role

do_response

logical calculate and return the responses?

...

additional arguments

Value

an updated recipe

See also

Other ols: step_nls()

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()