-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels