Package 'hedgedrf'

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-12-12 07:07:44 UTC
Source: CRAN

Help Index


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 formula or character describing the model to fit. Interaction terms supported only for numerical variables.

data

Training data of class data.frame, matrix, dgCMatrix (Matrix) or gwaa.data (GenABEL).

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 ranger function.

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 hedgedrf object.

data

data New test data of class data.frame or gwaa.data (GenABEL).

...

Additional arguments to pass to the predict.ranger function.

Value

The hedged random forest predictions. An object of class matrix.