step_distributed_lag
step_distributed_lag.Rd
Generates distributed lag vectors. For regular spaced lags this uses an FFT based method which is faster and more memory efficient.
Usage
step_distributed_lag(
.rec,
terms,
n_lag = 12L,
lag_max = 86400L,
knots = NA_real_,
basis_matrix = NA_real_,
intercept = FALSE,
role = "predictor",
...
)
Arguments
- .rec
the R6 recipe object.
- terms
the unquoted names of the variables to use or a selector function. terms replaces the `...` of the recipes package but requires variables to be included within `c()`. For example to include variables x and y you would write `c(x,y)` in the hydrorecipes package.
- n_lag
number of lags to calculate (enter either lag_max and n_lag or knots)
- lag_max
maximum lag to calculate (enter either lag_max and n_lag or knots)
- knots
specify the knot locations
- basis_matrix
user specified basis_matrix
- intercept
include intercept in basis matrix
- role
character - the name of the role
- ...
additional arguments
References
Gasparrini, A., 2011. Distributed Lag Linear and Non-Linear Models in R: The Package dlnm. Journal of statistical software 465 43, 1–20.
Examples
formula <- as.formula(y~x)
rows <- 1e4
dat <- data.frame(x = rnorm(rows),
y = as.numeric(1:rows),
z = rnorm(rows))
frec = recipe(formula = formula, data = dat) |>
step_distributed_lag(x, knots = hydrorecipes:::log_lags_arma(6, 800))