Problem with posterior_predict(..., nsamples=1) for categorical brms model

Hi,
I am getting this error:

Error in insert_refcat(eta, family = prep$family) :
is.matrix(eta) is not TRUE

When trying to predict one new sample, not with more samples, with this model:

dat <- data.frame(x=as.factor(c("A", "A", "A", "B", "B", "B")),
                  y=as.factor(c("A", "A", "B", "B", "B", "A")))

mod1 <- brm(bf(y ~ x), data = dat, 
              family = categorical(link = "logit"), 
              iter=3000, warmup=1000, cores=2, chains=2, 
              control = list(max_treedepth = 11))

newdat <- data.frame(x=c("A","B"), y=c("A", "B"))
posterior_predict(mod1, newdata = newdat, scale="response", nsamples=2) # works
posterior_predict(mod1, newdata = newdat, scale="response", nsamples=1) # gives the above error

Perhaps, this is a bug.

  • Operating System: Windows 10
  • brms Version: 2.13.5
  • R version: 3.6.3

Thanks. I will check and fix it.

Should be fixed on github now.