ropensci / dynamite

Bayesian Inference of Complex Panel Data
https://docs.ropensci.org/dynamite/
GNU General Public License v3.0
27 stars 1 forks source link

Binomial formula without `trials` should throw an early error #41

Closed helske closed 2 years ago

helske commented 2 years ago
set.seed(0)
timepoints <- 10
individuals <- 5
total_obs <- timepoints * individuals

test_data <- data.frame(
  time = 1:timepoints,
  group = gl(individuals, timepoints),
  trials = sample(50:100, size = total_obs, replace = TRUE)
) |>
  dplyr::mutate(
    y = rbinom(n = total_obs, size = trials, prob = 0.75),  
    x = rnorm(total_obs)
  )

Without trials does not throw an error:

fit<-dynamite(obs(y ~ x, "binomial"), 
  data = test_data, "group", "time", debug = list(no_compile = TRUE))

But there is (obviously) no trials_y in fit$stan$model_vars so sampling will fail.