Skip to content

RFA package for implementing random forest adjustment.

Notifications You must be signed in to change notification settings

milesdwilliams15/RFA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RFA

R-version updated version license encoding orchid

RFA is an R package for implementing random forest adjustment (RFA). RFA is a regression adjustment approach that partials out variation in a response and explanatory variable of interest given a set of covariates using random forests. The latest version of the package relies on ranger, which is a fast implementation of random forests. To learn more about the method, download my latest working paper here. For a more comprehensive summary of how to implement RFA in R, see the RFA vignette.

Installation

To install and attach the latest version of RFA, enter:

devtools::install_github("milesdwilliams15/RFA")
library(RFA)

Usage

RFA relies on ranger to implement random forests, and estimatr to perform linear regression on the random forest adjusted explanatory variable and response.

For a generic dataset, dataset, that contains vectors of some response variable y, an explanatory variable of interest z, and a set of confounding covariates x1, x2, and x3, random forest adjusted estimates are obtained by entering:

rfa(
  y ~ z,
  covariates = ~ x1 + x2 + x3,
  data = dataset
)

The function returns a list consisting of an estimatr::lm_robust object, the computed random forest regressions for the response and explanatory variable (ranger::ranger objects), and the dataset used to generate random forest adjusted estimates with the partialized versions of the response and explanatory variable appended.

About

RFA package for implementing random forest adjustment.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages