Help calculating log-likelihood with binomial_logit_glm to use with loo

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

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)

[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

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

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?

All of these work and report all K estimates < 0.5

Thank you all very much!!

1 Like