# Brms predict function bug

**URL:** https://discourse.mc-stan.org/t/brms-predict-function-bug/35652
**Category:** brms
**Tags:** brms
**Created:** [June 26, 2024, 8:52pm UTC](https://discourse.mc-stan.org/t/brms-predict-function-bug/35652 "2024-06-26T20:52:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rogerzzz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rogerzzz/32/18088_2.png) [@rogerzzz](https://discourse.mc-stan.org/u/rogerzzz)
#### Post date: [June 26, 2024, 8:52pm UTC](https://discourse.mc-stan.org/t/brms-predict-function-bug/35652/1 "2024-06-26T20:52:35Z")

</div>

Short summary of the problem

Hello, I am now training a BRMS model which includes a series of equations, and one of them is a categorical response. While I am trying to evaluate prediction results using training data, I encounter the following issue:

the following three lines does not have any bug and returns results

```no-highlight
head(fitted(ms_100K_jun26, newdata=dc_100K_jun26[1:10,]), type="response")
head(posterior_epred(ms_100K_jun26, newdata=dc_100K_jun26[1:10,]), type="response")
head(posterior_predict(ms_100K_jun26, newdata=dc_100K_jun26[1:10,]), type="response")

```

However, when running the following line with “predict” function it throws dimension error:

```no-highlight
predict(ms_100K_jun26, newdata=dc_100K_jun26[1:10,]), type="response"

Error in .fun(conv = .x1, ftitlelength = .x2, fdescriptionlength = .x3, : 
  arg 'condition' has dims=10, 8, 1; but need dims=10, 4, X

```

I dont understand this. Given predict is a wrapper on top of posterior\_predict, I am guessing there is some bug in this function, rather in my model training. But I cannot debug with this limited error information. Could you please provide some insights?

---

<div class="post-metadata">

### Author: ![jsocolar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jsocolar/32/2486_2.png) [@jsocolar](https://discourse.mc-stan.org/u/jsocolar)
#### Post date: [June 26, 2024, 10:14pm UTC](https://discourse.mc-stan.org/t/brms-predict-function-bug/35652/2 "2024-06-26T22:14:28Z")

</div>

Just checking: in every case above, you put `, type="response"` outside of the relevant close parenthesis. Is this a copy-paste error, or is it a problem in your r script as well?

---

<div class="post-metadata">

### Author: ![rogerzzz](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rogerzzz/32/18088_2.png) [@rogerzzz](https://discourse.mc-stan.org/u/rogerzzz)
#### Post date: [June 27, 2024, 3:11pm UTC](https://discourse.mc-stan.org/t/brms-predict-function-bug/35652/3 "2024-06-27T15:11:48Z")

</div>

Thanks @jsocolar for pointing it out. Yes it is a typo. But it doesnt seem to be the reason of the bug:

```no-highlight
> head(predict(ms_100K_jun26, newdata=dc_100K_jun26[1:10,],type="response"))
Error in .fun(conv = .x1, ftitlelength = .x2, fdescriptionlength = .x3, : 
  arg 'condition' has dims=10, 8, 1; but need dims=10, 4, X

```

and the others still return the prediction.
