Syntax error using multi logit regression example

I am trying to fit a multi logit regression. If I use the code in the user guide :

data {
  int K;
  int N;
  int D;
  int y[N];
  matrix[N, D] x;
parameters {
  matrix[D, K] beta;
model {
  matrix[N, K] x_beta = x * beta;

  to_vector(beta) ~ normal(0, 2);

  for (n in 1:N)
    y[n] ~ categorical_logit(x_beta[n]);

I get the following syntax errors:


Unknown variable: to_vector
No matches for: 

  int ~ categorical_logit(row vector)

Available argument signatures for categorical_logit:

  int ~ categorical_logit(vector)
  int[] ~ categorical_logit(vector)

require real scalar return type for probability function.

Lastly I think that the normal(0,5) priors specified in the text do not match that declared in the code.

Apparently, the categorical_logit function cannot accept a row_vector. You have to transpose x_beta[n].

1 Like

thanks @bgoodri! Do you think should I propose an issue for the documentation?

The documentation and parser error are correct

It is just there is really no reason for the code to be limited to a vector.

I was talking about this code

Oh. Yeah, that is wrong.

thanks for pointing this out. could you add a comment to this issue:

1 Like