Error using pp_check with categorical model in brms


#1

Operating System Ubuntu 16.04, Version 2.3.0 cran (I also tried the latest from github), R 3.4.2:

Hi, thank you for this great package.

I’m still learning the bayesian ropes, especially with brms, so I’m probably just misunderstanding something basic.

I’d like to make a diagnostic plot (pp_check) as a figure in a paper, but it gives the following error:

library(brms)
data(“iris”)
mod <- brm(
Species ~ Sepal.Length,
data = iris,
family = categorical,
chains = 2, iter = 300
)

pp_check(mod)

Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, :
‘max’ not meaningful for factors

Are these posterior barplots possible with categorical models? Somehow I thought it would be hooking into http://mc-stan.org/bayesplot/reference/PPC-discrete.html .

Am I supposed to be giving pp_check extra switches when the distribution is categorical?

Thanks again!


#2

There is a problem somewhere in the code where factors are not converted to integers correctly. Let me check that.


#3

This should now be fixed in the latest dev version of brms from github to be installed via

if (!require("devtools")) {
  install.packages("devtools")
}
devtools::install_github("paul-buerkner/brms")

#4

This works great, thank you so much!