Error using pp_check using truncated response variable in brms


I’m getting started with brms, trying to fit a count model with zeros truncated out (as opposed to zero-inflating them). I noticed that running pp_check (of type rootogram) doesn’t work on the fitted model in this case.

Example code:


fishdata <- read.csv("")
fishdata_filt = fishdata[fishdata$count > 0, ]

fit_pois <- brm(count | trunc(lb=1) ~ persons + child + camper,
                 data = fishdata_filt, family = poisson())

pp_check(fit_pois, type = "rootogram", style="hanging")

Returns the error message:

Error in .fun(.x1, .x2, style = .x3): ppc_rootogram expects counts as inputs to 'yrep'.

1. pp_check(fit_pois, type = "rootogram", style = "hanging")
2. pp_check.brmsfit(fit_pois, type = "rootogram", style = "hanging")
3. run(ppc_fun, ppc_args)
4. eval2(call, envir = args, enclos = parent.frame())
5. eval(expr, envir, ...)
6. eval(expr, envir, ...)
7. .fun(.x1, .x2, style = .x3)
8. stop("ppc_rootogram expects counts as inputs to 'yrep'.")

If I remove the | trunc(lb=1) part of the formula, everything works fine (although the model fits poorly).

Unfortunately I don’t understand R well enough to parse the error message. Is pp_check expected to work under circumstances like these?

Thanks in advance for your help.

Version information:

  • Operating System: macOS 10.12.6
  • brms Version: 2.7.0
1 Like

Thanks for reporting this issue and also, in particular, for directly providing a reproducible example!

I have fixed the problem in github version of brms to be installed via

if (!requireNamespace("devtools")) {
1 Like

Thanks for fixing! My error is resolved by using the github version.