| 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 |
Prediction of test data using Regression-Enhanced Random Forests.
## S3 method for class 'RegEnRF' predict(object, newx, ...)## S3 method for class 'RegEnRF' predict(object, newx, ...)
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. |
A vector of predicted values.
set.seed(111) x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) mod <- RegEnRF(x, y, lambda = 0.1) predict(mod, newx = x)set.seed(111) x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) mod <- RegEnRF(x, y, lambda = 0.1) predict(mod, newx = x)
RegEnRF() implements Regression-Enhanced Random Forests algorithm (based on
Zhang et al., 2019 paper) for regression.
RegEnRF(x, y, lambda, ...)RegEnRF(x, y, lambda, ...)
x |
A numeric matrix of predictors. Requirement: nvars >1;
in other words, x should have 2 or more columns. This is a constraint
of |
y |
A numeric response vector. |
lambda |
See 'lambda' argument in |
... |
other arguments passed to |
This function is based on the packages randomForest::randomForest
and glmnet::glmnet.
An object with S3 class "RegEnRF"
Umberto Minora [email protected], based on the paper by Zhang et al. (2019).
Zhang, H., Nettleton, D., & Zhu, Z. (2019). Regression-enhanced random forests. arXiv preprint doi:10.48550/arXiv.1904.10416.
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"))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"))