Fits a linear quantile regression on a 'tidyFit' R6
class. The function can be used with regress
.
Arguments
- self
a 'tidyFit' R6 class.
- data
a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).
Details
Hyperparameters:
None. Cross validation not applicable.
Important method arguments (passed to m
)
tau
(the quantile(s) to be estimated)
The function provides a wrapper for quantreg::rq
. See ?rq
for more details. The argument tau
is the chosen quantile (default tau = 0.5
).
Implementation
No implementation notes
References
Koenker R (2022). quantreg: Quantile Regression. R package version 5.94, https://CRAN.R-project.org/package=quantreg.
See also
.fit.lm
, .fit.bayes
and m
methods
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
# Stand-alone function
fit <- m("quantile", Return ~ ., data, tau = 0.5)
fit
#> # A tibble: 1 × 6
#> estimator_fct `size (MB)` grid_id model_object settings warnings
#> <chr> <dbl> <chr> <list> <list> <chr>
#> 1 quantile::rq 4.57 #0010000 <tidyFit> <tibble> Solution may b…
# Within 'regress' function
fit <- regress(data, Return ~ .,
m("quantile", tau = c(0.1, 0.5, 0.9)),
.mask = c("Date", "Industry"))
coef(fit)
#> # A tibble: 21 × 5
#> # Groups: model [1]
#> model term estimate grid_id model_info
#> <chr> <chr> <dbl> <chr> <list>
#> 1 quantile (Intercept) -3.50 #0010000 <tibble [1 × 4]>
#> 2 quantile Mkt-RF 0.942 #0010000 <tibble [1 × 4]>
#> 3 quantile SMB -0.00520 #0010000 <tibble [1 × 4]>
#> 4 quantile HML 0.0928 #0010000 <tibble [1 × 4]>
#> 5 quantile RMW 0.132 #0010000 <tibble [1 × 4]>
#> 6 quantile CMA 0.00170 #0010000 <tibble [1 × 4]>
#> 7 quantile RF 0.677 #0010000 <tibble [1 × 4]>
#> 8 quantile (Intercept) -0.0937 #0020000 <tibble [1 × 4]>
#> 9 quantile Mkt-RF 0.984 #0020000 <tibble [1 × 4]>
#> 10 quantile SMB 0.0373 #0020000 <tibble [1 × 4]>
#> # ℹ 11 more rows