| Title: | An Implementation of the Hedged Random Forest Algorithm | 
| Version: | 1.0.1 | 
| Description: | This algorithm is described in detail in the paper "Hedging Forecast Combinations With an Application to the Random Forest" by Beck et al. (2024) https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5032102. 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. | 
| License: | GPL-3 | 
| Imports: | ranger, CVXR | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.1 | 
| NeedsCompilation: | no | 
| Packaged: | 2025-03-12 14:19:44 UTC; ubuntu | 
| Author: | Elliot Beck | 
| Maintainer: | Elliot Beck <elliotleeroy.beck@uzh.ch> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-03-12 16:00:02 UTC | 
Quadratic-inverse shrinkage
Description
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).
Usage
get_cov_qis(data, k = -1)
Arguments
| 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. | 
Value
sigmahat (p*p): the QIS covariance matrix estimate. An object of
class matrix.
hedgedrf
Description
hedgedrf
Usage
hedgedrf(
  formula = NULL,
  data = NULL,
  x = NULL,
  y = NULL,
  num_iter = NULL,
  kappa = 2,
  ...
)
Arguments
| 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  | 
Value
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.
Examples
rf <- hedgedrf(mpg ~ ., mtcars[1:26, ])
pred <- predict(rf, mtcars[27:32, ])
pred
hedgedrf prediction
Description
hedgedrf prediction
Usage
## S3 method for class 'hedgedrf'
predict(object, data, ...)
Arguments
| object | hedgedrf  | 
| data | data New test data of class  | 
| ... | Additional arguments to pass to the  | 
Value
The hedged random forest predictions. An object of class matrix.