Fits a nonlinear quantile regression forest on a 'tidyFit' R6
class. The function can be used with regress
.
Details
Hyperparameters:
ntree (number of trees)
mtry (number of variables randomly sampled at each split)
Important method arguments (passed to m
)
tau
(the quantile(s) to be estimated)
The function provides a wrapper for quantregForest::quantregForest
. See ?quantregForest
for more details.
The argument tau
is the chosen quantile (default tau = 0.5
).
tau
is passed directly to m('quantile_rf', tau = c(0.1, 0.5, 0.9)
and is not passed to predict
as in the quantregForest::quantregForest
package. This is done to ensure a consistent interface with the quantile regression from quantreg
.
Implementation
No implementation notes
References
Meinshausen N (2017). quantregForest: Quantile Regression Forests. R package version 1.3-7, https://CRAN.R-project.org/package=quantregForest.
See also
.fit.quantile
, .fit.rf
and m
methods
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
data <- dplyr::filter(data, Industry == "HiTec")
data <- dplyr::select(data, -Date, -Industry)
# Stand-alone function
fit <- m("quantile_rf", Return ~ ., data, tau = 0.5, ntree = 50)
fit
#> # A tibble: 1 × 5
#> estimator_fct `size (MB)` grid_id model_object settings
#> <chr> <dbl> <chr> <list> <list>
#> 1 quantregForest::quantregForest 1.26 #00100… <tidyFit> <tibble>
# Within 'regress' function
fit <- regress(data, Return ~ .,
m("quantile_rf", tau = c(0.1, 0.5, 0.9), ntree = 50))
explain(fit)
#> Warning: using explain package 'randomForest'
#> # A tibble: 7 × 5
#> # Groups: model [1]
#> model term importance IncNodePurity importanceSD
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 quantile_rf (Intercept) 0 0 0
#> 2 quantile_rf Mkt-RF 37.5 14685. 1.56
#> 3 quantile_rf SMB 0.500 2104. 0.354
#> 4 quantile_rf HML 3.83 3022. 0.638
#> 5 quantile_rf RMW 1.96 2543. 0.316
#> 6 quantile_rf CMA 4.19 4502. 0.743
#> 7 quantile_rf RF 0.690 1306. 0.226