Practical overview
When it fits
Use Grf when an R analysis calls for non-parametric forest-based estimation, particularly when treatment effects may vary across observations or outcomes are right-censored.
Who it is for
- Researchers and analysts conducting treatment-effect or causal-inference analysis in R.
- Users seeking forest-based regression, quantile or survival estimation.
Documented uses
- Estimate heterogeneous treatment effects and predict them for new covariate data.
- Calculate average treatment effects for a specified target sample.
- Fit least-squares, quantile or survival regression forests.
- Analyze outcomes that may be right-censored, with multiple treatment arms or outcomes, or instrumental variables.
Requirements & limits
The package is open source under GPL-3.0. The repository documents installation through CRAN and conda-forge; source installation requires a C++17-or-later compiler, and Windows source installation also requires RTools.
- Grf is an R package with C++ implementation, not a hosted analytics interface.
- Its methods include causal, regression, quantile and survival forests; the appropriate forest depends on the analysis task.
- Source installation has compiler prerequisites, while the README also documents CRAN and conda-forge installation routes.
- The examples show prediction, average treatment effects and confidence intervals; confidence-interval examples use a larger forest.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Fit and predict with a causal forest
Estimate heterogeneous treatment effects and obtain predictions for a test sample.
Before you start
- The
grfR package. - Covariate matrix
X, outcome vectorY, treatment indicatorW, and test covariatesX.test.
Steps
Load the package with
library(grf).Fit a forest with
tau.forest <- causal_forest(X, Y, W).Estimate test-sample treatment effects with
tau.hat <- predict(tau.forest, X.test).Optionally estimate an average effect with
average_treatment_effect(tau.forest, target.sample = "all")or usetarget.sample = "treated".
Expected outcome
The fitted forest provides treatment-effect predictions for the test data and can estimate an average effect for the selected target sample.
Guide limitations
- The guide does not prescribe data preparation or establish that a particular dataset is suitable for causal inference.
- Confidence intervals require variance estimation; the example uses a larger forest with 4,000 trees.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 13 October 2026
- Original website title
- grf-labs/grf · Official homepage title · retained in its source language

