Title: | An Implementation of the Hedged Random Forest Algorithm |
---|---|
Description: | This algorithm is described in detail in the paper "Hedging Forecast Combinations With an Application to the Random Forest" by Beck et al. (2023) <doi:10.48550/arXiv.2308.15384>. The package provides a function hedgedrf() that can be used to train a Hedged Random Forest model on a dataset, and a function predict.hedgedrf() that can be used to make predictions with the model. |
Authors: | Elliot Beck [aut, cre] |
Maintainer: | Elliot Beck <[email protected]> |
License: | GPL-3 |
Version: | 0.0.1 |
Built: | 2024-11-12 06:52:50 UTC |
Source: | CRAN |
Nonlinear shrinkage derived under Frobenius loss and its two cousins, Inverse Stein’s loss and Minimum Variance loss, called quadratic-inverse shrinkage (QIS). See Ledoit and Wolf (2022, Section 4.5).
get_cov_qis(data, k = -1)
get_cov_qis(data, k = -1)
data |
(n*p): raw data matrix of n iid observations on p random variables |
k |
If k < 0, then the algorithm demeans the data by default, and adjusts the effective sample size accordingly. If the user inputs k = 0, then no demeaning takes place; if user inputs k = 1, then it signifies that the data data have already been demeaned. |
sigmahat (p*p): the QIS covariance matrix estimate. An object of
class matrix
.
hedgedrf
hedgedrf( formula = NULL, data = NULL, x = NULL, y = NULL, num_iter = NULL, kappa = 2, ... )
hedgedrf( formula = NULL, data = NULL, x = NULL, y = NULL, num_iter = NULL, kappa = 2, ... )
formula |
Object of class |
data |
Training data of class |
x |
Predictor data (independent variables), alternative interface to data with formula or dependent.variable.name. |
y |
Response vector (dependent variable), alternative interface to data with formula or dependent.variable.name. For survival use a Surv() object or a matrix with time and status. |
num_iter |
Number of iterations for the optimization algorithm. |
kappa |
Amount of regularization to apply to the tree weights. 1 implies no shorting, 2 implies no more than 50% shorting, etc. |
... |
Additional arguments to pass to the |
An object of class hedgedrf
containing the tree weights and
a ranger object. The tree weights can be used to construct a hedged random
forest with the predict.hedgedrf
function. For more details about the
ranger object, see the ranger documentation.
rf <- hedgedrf(mpg ~ ., mtcars[1:26, ]) pred <- predict(rf, mtcars[27:32, ]) pred
rf <- hedgedrf(mpg ~ ., mtcars[1:26, ]) pred <- predict(rf, mtcars[27:32, ]) pred
hedgedrf prediction
## S3 method for class 'hedgedrf' predict(object, data, ...)
## S3 method for class 'hedgedrf' predict(object, data, ...)
object |
hedgedrf |
data |
data New test data of class |
... |
Additional arguments to pass to the |
The hedged random forest predictions. An object of class matrix
.