Package 'RegEnRF'

Title: Regression-Enhanced Random Forests
Description: A novel generalized Random Forest method, that can improve on RFs by borrowing the strength of penalized parametric regression. Based on Zhang et al. (2019) <doi:10.48550/arXiv.1904.10416>.
Authors: Umberto Minora [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-2151-6500>)
Maintainer: Umberto Minora <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0.9000
Built: 2026-05-25 07:01:47 UTC
Source: https://github.com/umbe1987/regenrf

Help Index


Prediction of test data using Regression-Enhanced Random Forests.

Description

Prediction of test data using Regression-Enhanced Random Forests.

Usage

## S3 method for class 'RegEnRF'
predict(object, newx, ...)

Arguments

object

an object of class "RegEnRF", as that created by the function RegEnRF

newx

matrix of new values for x at which predictions are to be made function will abort.

...

other arguments passed to glmnet::predict.glmnet and randomForest:::predict.randomForest.

Value

A vector of predicted values.

Examples

set.seed(111)
x <- matrix(rnorm(100 * 20), 100, 20)
y <- rnorm(100)
mod <- RegEnRF(x, y, lambda = 0.1)
predict(mod, newx = x)

Regression-Enhanced Random Forests

Description

RegEnRF() implements Regression-Enhanced Random Forests algorithm (based on Zhang et al., 2019 paper) for regression.

Usage

RegEnRF(x, y, lambda, ...)

Arguments

x

A numeric matrix of predictors. Requirement: nvars >1; in other words, x should have 2 or more columns. This is a constraint of glmnet::glmnet().

y

A numeric response vector.

lambda

See 'lambda' argument in glmnet::glmnet().

...

other arguments passed to glmnet::glmnet() and randomForest::randomForest().

Details

This function is based on the packages randomForest::randomForest and glmnet::glmnet.

Value

An object with S3 class "RegEnRF"

Author(s)

Umberto Minora [email protected], based on the paper by Zhang et al. (2019).

References

Zhang, H., Nettleton, D., & Zhu, Z. (2019). Regression-enhanced random forests. arXiv preprint doi:10.48550/arXiv.1904.10416.

Examples

set.seed(111)
data(co2)
x <- matrix(c(time(co2), cycle(co2)), ncol = 2)
y <- as.numeric(co2)
mod <- RegEnRF(x, y, lambda = 0.1)
freq <- frequency(co2)
startt <- tsp(co2)[2] + 1 / freq
xnew.t <- seq(startt, by = 1 / freq, length.out = freq * 3)
xnew <- matrix(c(xnew.t, cycle(tail(co2, freq * 3))), ncol = 2)
pred <- predict(mod, xnew)
pred.ts <- ts(pred, start = startt, frequency = freq)
plot(ts.union(co2, pred.ts), plot.type = "single", col = c("black", "red"))