-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
57 lines (43 loc) · 1.51 KB
/
Copy pathREADME.Rmd
File metadata and controls
57 lines (43 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# RegEnRF
<!-- badges: start -->
[](https://github.com/umbe1987/regenrf/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
`RegEnRF` is the implementation of the Regression-Enhanced Random Forests algorithm as described in [Zhang et al. (2019)](https://doi.org/10.48550/arXiv.1904.10416).
## Installation
You can install RegEnRF like so:
``` r
install.packages("RegEnRF")
```
or the development version like so:
``` r
devtools::install_github("umbe1987/regenrf")
```
## Example
This is an example showing how to perform Regression-Enhanced Random Forests with `RegEnRF`. It demonstrates how `RegEnRF` can extrapolate beyond the training domain, as opposed to `randomForest`.
```{r example}
library(RegEnRF)
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"))
```