Fits a nonlinear quantile regression forest 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:
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.27 #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 34.6 13625. 1.52
#> 3 quantile_rf SMB 1.07 2313. 0.393
#> 4 quantile_rf HML 5.85 4104. 0.749
#> 5 quantile_rf RMW 1.97 3027. 0.439
#> 6 quantile_rf CMA 5.66 4178. 0.660
#> 7 quantile_rf RF 0.938 1208. 0.327