With tidybayes 3.0.7 the following code throws an error...
# Fitting a toy binomial model to estimate an overall probability of success
library(rstanarm)
library(tidybayes)
# Simulate some data
true_prob <- 0.25
n <- sample(10:20, 20, replace = TRUE)
y <- rbinom(20, n, true_prob)
dat <- data.frame(hits = y, misses = n - y)
# Fit an intercept-only model
m <- stan_glm(cbind(hits, misses) ~ 1, data = dat, family = binomial())
# This provokes an error...
post <- tidy_draws(m)
The problem seems to be due to this code in tidy_draws.mcmc.list()...
draws = do.call(rbind, lapply(seq_along(model), function(chain) {
n = nrow(model[[chain]])
iteration = seq_len(n)
...where model is the mcmc.list object. Because the fitted model only has an intercept, the object model[[chain]] will be a vector, so nrow() will return NULL causing the seq_len(n) to crash.
I'm probably doing something wrong here (i.e. user error rather than package bug) but haven't been able to spot it.
With tidybayes 3.0.7 the following code throws an error...
The problem seems to be due to this code in
tidy_draws.mcmc.list()......where
modelis the mcmc.list object. Because the fitted model only has an intercept, the objectmodel[[chain]]will be a vector, sonrow()will return NULL causing theseq_len(n)to crash.I'm probably doing something wrong here (i.e. user error rather than package bug) but haven't been able to spot it.