Hey all,

I am very new to Stan (and modelling in general). I have been following McElreath’s classes + reading his book to get an introduction, and I’ve tried applying a beta-binomial distribution to real life samples. The samples are very overdispersed and I would like to model the overdispersion by group-at least to see on which occasion the overdispersion is larger.

Using the tadpoles example (m12.1), I applied it to my data with this code:

```
m12.1 <- ulam(
alist(
P ~ dbetabinom( N , pbar , theta ),
logit(pbar) <- a[TC_id],
a[TC_id] ~ dnorm( 0 , 1.5 ),
theta <- phi[TC_id] + 2.0,
phi[TC_id] ~ dexp(1)
), data=dat , chains=4
)
```

where:

- P are counts.
- N is the total sample size.
- TC_id indicates an interaction between two categorical variables (1 <= TC_id <= 8). For the reason mentioned above, ideally, I wanted to get theta results for each TC_id. The following code however does not work:

`22: P ~ beta_binomial( N , pbar*theta , (1-pbar)*theta );`

`Ill-typed arguments supplied to infix operator *. Available signatures: [...] Instead supplied arguments of incompatible type: vector, vector.`

I apologise if the code is poorly written, I have just started approaching these topics. The model works fine if phi is not followed by [TC_id]. I have also tried using something like vector[8]:, but I am still getting an error.

Thank you in advance for your help!