1

I am trying to run causal_forest in R but it is taking forever and it shouldn't be (because my friends are using the same file and are not encountering this issue). I am using RStudio as well. Does anyone know how to solve this problem?

Note that the dataset I am using is called JTPA. These are the libraries I am using:

library(tidyverse)
library(randomForest)
library(glmnet)
library(grf)
library(tree)

My first issue was I would run the code but then receive this error:

options(na.action='na.pass')
X = model.matrix(earnings ~ . -treatment, JTPA)[,-1]
W = JTPA$treatment
Y = JTPA$earnings

set.seed(123)
forest.fit = causal_forest(X, Y, W, num.trees = 2000)

Error in (function (train_matrix, outcome_index, sample_weight_index,: function 'Rcpp_precious_remove' not provided by package 'Rcpp'

I shouldn't have needed to use this package (at least I think), so I prefixed the function with grf::.

forest.fit = grf::causal_forest(X, Y, W, num.trees = 2000)

This resulted in R running for over an hour at which point I terminated the console. But this also had weird behavior because terminating the console didn't stop the code from running so I had to force exit from RStudio.

Then, I took out the prefix but also included the Rccp library. So my line of interest reverted back to the original. However, I still had the same problem as when I prefixed with grf::.

library(Rcpp)
forest.fit = causal_forest(X, Y, W, num.trees = 2000)
pizzajona
  • 21
  • 4

0 Answers0