quantile_reg()
generates a quantile regression model specification for
the tidymodels framework. Currently, the
only supported engines are "rq", which uses quantreg::rq()
.
Quantile regression is also possible by combining parsnip::rand_forest()
with the grf
engine. See grf_quantiles.
Usage
quantile_reg(
mode = "regression",
engine = "rq",
quantile_levels = c(0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95),
method = "br"
)
Arguments
- mode
A single character string for the type of model. The only possible value for this model is "regression".
- engine
Character string naming the fitting function. Currently, only "rq" and "grf" are supported.
- quantile_levels
A scalar or vector of values in (0, 1) to determine which quantiles to estimate (default is the set 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95).
- method
A fitting method used by
quantreg::rq()
. See the documentation for a list of options.
Examples
library(quantreg)
#> Loading required package: SparseM
tib <- data.frame(y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100))
rq_spec <- quantile_reg(quantile_levels = c(.2, .8)) %>% set_engine("rq")
ff <- rq_spec %>% fit(y ~ ., data = tib)
predict(ff, new_data = tib)
#> # A tibble: 100 × 1
#> .pred
#> <qtls(2)>
#> 1 [0.291]
#> 2 [-0.452]
#> 3 [0.162]
#> 4 [-0.0806]
#> 5 [-0.375]
#> 6 [-0.251]
#> 7 [-0.284]
#> 8 [0.0113]
#> 9 [-0.136]
#> 10 [-0.474]
#> # ℹ 90 more rows