Description Usage Arguments Value Examples

View source: R/regression_forest.R

Gets estimates of E[Y|X=x] using a trained regression forest.

1 2 3 4 5 |

`object` |
The trained forest. |

`newdata` |
Points at which predictions should be made. If NULL, makes out-of-bag predictions on the training set instead (i.e., provides predictions at Xi using only trees that did not use the i-th training example). |

`linear.correction.variables` |
Optional subset of indexes for variables to be used in local linear prediction. If NULL, standard GRF prediction is used. Otherwise, we run a locally weighted linear regression on the included variables. Please note that this is a beta feature still in development, and may slow down prediction considerably. Defaults to NULL. |

`ll.lambda` |
Ridge penalty for local linear predictions |

`ll.weight.penalty` |
Option to standardize ridge penalty by covariance (TRUE), or penalize all covariates equally (FALSE). Defaults to FALSE. |

`num.threads` |
Number of threads used in training. If set to NULL, the software automatically selects an appropriate amount. |

`estimate.variance` |
Whether variance estimates for hattau(x) are desired (for confidence intervals). |

`...` |
Additional arguments (currently ignored). |

A vector of predictions.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
## Not run:
# Train a standard regression forest.
n = 50; p = 10
X = matrix(rnorm(n*p), n, p)
Y = X[,1] * rnorm(n)
r.forest = regression_forest(X, Y)
# Predict using the forest.
X.test = matrix(0, 101, p)
X.test[,1] = seq(-2, 2, length.out = 101)
r.pred = predict(r.forest, X.test)
# Predict on out-of-bag training samples.
r.pred = predict(r.forest)
# Predict with confidence intervals; growing more trees is now recommended.
r.forest = regression_forest(X, Y, num.trees = 100)
r.pred = predict(r.forest, X.test, estimate.variance = TRUE)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.