jaredsmurray / bcf

Bayesian Causal Forests
40 stars 20 forks source link

mathematica-mpr/coda dependency? #7

Closed ignacio82 closed 2 years ago

ignacio82 commented 4 years ago

I noticed that this package depends on a fork of coda. Do you know if this fork will be either merger into the upstream coda project or submitted to cran? Their Github repo does not accept issues, and it seems like this is the only project that uses it so I thought I could ask here.

I'm asking because it seems like this fork breaks compatibility with other R packages. For example:

remotes::install_github('mathematica-mpr/coda', force = TRUE)
library(dplyr)
library(dbarts)
set.seed(123)
N <- 120

my_data <-
  tibble(Z = sample(
    x = c("treatment", "control"),
    size = N,
    replace = TRUE,
    p = c(0.5, 0.5)
  )) %>%
  rowwise()  %>%
  mutate(
    treatment = case_when(Z == "treatment" ~ 1,
                          Z == "control" ~ 0),
    X = case_when(
      Z == "treatment" ~ rnorm(1, mean = 40, sd = 10),
      Z == "control" ~ rnorm(1, mean = 20, sd = 10)
    ),
    Y1 = rnorm(1, mean = 90 + exp(0.06 * X), sd = 1),
    Y0 = rnorm(1, mean = 72 + 3 * sqrt(X), sd = 1),
    Y = case_when(Z == "treatment" ~ Y1,
                  Z == "control" ~ Y0),
    tau = Y1 - Y0
  ) %>%
  tidyr::drop_na() #  remove NAs from negative X's

train_data <- dbartsData(my_data %>% select(X, treatment), my_data$Y)

fit <- bart2(
  train_data,
  keepTrees       = T,
  verbose         = F,
  n.thread        = 6,
  combineChains   = TRUE
)

neff_sigma <- coda::effectiveSize(x = fit$sigma)

Produces this error:

Error in coda::effectiveSize(x = fit$sigma) : object 'ans' not found

cc: @cdelannoy @marielfinucane @TychonautVII