# Help calculating log-likelihood with binomial\_logit\_glm to use with loo

**URL:** <https://discourse.mc-stan.org/t/help-calculating-log-likelihood-with-binomial-logit-glm-to-use-with-loo/28328>\
**Category:** Modeling\
**Tags:** loo, fitting-issues, specification\
**Created:** [July 26, 2022, 5:34pm UTC](https://discourse.mc-stan.org/t/help-calculating-log-likelihood-with-binomial-logit-glm-to-use-with-loo/28328 "2022-07-26T17:34:15Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![JLC](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jlc/32/12520_2.png) [@JLC](https://discourse.mc-stan.org/u/JLC)\
**Post date:** [August 2, 2022, 6:59pm UTC](https://discourse.mc-stan.org/t/help-calculating-log-likelihood-with-binomial-logit-glm-to-use-with-loo/28328/21 "2022-08-02T18:59:46Z")

</div>

Adding the `{ }` compiles, but throws the following error on each iteration after warmup

```nohighlight
Exception: bernoulli_logit_glm_lpmf: Vector of dependent variables has dimension = 1, expecting dimension = 1296; a function was called with arguments of different scalar, array, vector, or matrix types, and they were not consistently sized; all arguments must be scalars or multidimensional values of the same shape. (in '/tmp/RtmpFpLq0i/model-b613e733b2a59.stan', line 174, column 16 to column 94)

```

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [August 3, 2022, 11:05am UTC](https://discourse.mc-stan.org/t/help-calculating-log-likelihood-with-binomial-logit-glm-to-use-with-loo/28328/22 "2022-08-03T11:05:31Z")

</div>

```nohighlight
[quote="JLC, post:21, topic:28328"]
Adding the `{ }` compiles
[/quote]

```

Bob suggested adding {} for Y[n] and for X[n], so just checking how does tour code actually look like now? With Y[n] and X[n] the signature was  
(int, row\_vector, real, vector)  
and it’s a bug that it doesn’t work. Based on the signatures you had available

```nohighlight
Available signatures:
(int, matrix, vector, vector) => real
  The second argument must be matrix but got row_vector
(int, matrix, real, vector) => real
  The second argument must be matrix but got row_vector
(array[] int, matrix, vector, vector) => real
  The first argument must be array[] int but got int
(array[] int, row_vector, real, vector) => real
  The first argument must be array[] int but got int
(array[] int, row_vector, vector, vector) => real
  The first argument must be array[] int but got int
(Additional signatures omitted)

```

all the following should work

```nohighlight
bernoulli_logit_glm_lpmf(Y1[n] | [X[n]], mu_y1_pred[n], b_y1);
bernoulli_logit_glm_lpmf({Y1[n]} | X[n], mu_y1_pred[n], b_y1);
bernoulli_logit_glm_lpmf({Y1[n]} | [X[n]], mu_y1_pred[n], b_y1);

```

Can you repor if one or more of this doesn’t work?

---

<div class="post-metadata">

**Author:** ![JLC](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jlc/32/12520_2.png) [@JLC](https://discourse.mc-stan.org/u/JLC)\
**Post date:** [August 3, 2022, 12:22pm UTC](https://discourse.mc-stan.org/t/help-calculating-log-likelihood-with-binomial-logit-glm-to-use-with-loo/28328/23 "2022-08-03T12:22:05Z")

</div>

All of these work and report all K estimates \< 0.5

Thank you all very much!!

[Previous page](https://discourse.mc-stan.org/t/help-calculating-log-likelihood-with-binomial-logit-glm-to-use-with-loo/28328.md?page=1)
