Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorize predictors in categorical(_logit) #3102

Open
bob-carpenter opened this issue Aug 12, 2024 · 0 comments
Open

Vectorize predictors in categorical(_logit) #3102

bob-carpenter opened this issue Aug 12, 2024 · 0 comments
Labels

Comments

@bob-carpenter
Copy link
Contributor

Description

As is, the categorical and categorical_logit pdfs allow multiple outputs, but not multiple parameters.

This was requested in docs, but doesn't exist yet: stan-dev/docs#500

Example

Currently:

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

What we want is to add the following signature in the usual way (so that each row of the matrix corresponds to an entry of the integer array):

(array[] int, matrix) => real

and maybe

(array[] int, array[] vector) => real

The goal is to support vectorized code that looks like this:

data {
  int<lower=0> K;
  int<lower=0> N;
  int<lower=0> D;
  array[N] int<lower=1, upper=K> y;
  matrix[N, D] x;
}
parameters {
  matrix[D, K] beta;
}
model {
  to_vector(beta) ~ normal(0, 5);
  y ~ categorical_logit(x * beta);
}

Expected Output

Above example compiles.

Current Version:

v4.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant