# Hierarchical multi-logit regression

#21

Excellent. Thanks a bunch for the suggestion. The model was taking about 18 hours to run before, so the speed increase will be a big help.

~Colin

#22

Hi All,

I am a new stan user working with a multinomial regression. I encountered the same K vs. K-1 issue. Initially I was using the softmax to normalize my probabilities, however following the advice here and from an older discussion (https://github.com/stan-dev/stan/issues/266) I switched to categorical_logit.

When I run the model I see that it does not contain any samples, yet it does not throw an errors so I’m not sure how to diagnose the issue. Perhaps I am misunderstanding how categorical_logit is implemented in stan?

data{
int<lower=0> P; // number of subjects
int<lower=0> T; // number of dates
int<lower=0> N; // number of observations

int<lower=0> y[N, 3]; // vector of multinomial counts
int<lower=0> n[N]; // vector of samples
int<lower=0> t[N]; // vector of date indices
int<lower=0> id[N]; // vector of subject indices
}

parameters{
matrix[T, 2] theta; // parameter associated with each date
matrix[P, 2] epsilon; // bias parameter associated with each subject
}

model{
for(ii in 1:N) y[ii,] ~ categorical_logit( c(theta[t[ii],]+epsilon[id[ii],], 0) );
}

#23

I think you want `multinomial`, not `categorical`, if I understand your comments. The difference in what they expect for `y` is explained in the manual (categorical wants a single outcome, multinomial a vector of counts).

#24

Yes that seems to do the trick. Thanks for the help!

#25

Hi,

Has anyone tried to code a hierarchical multi-logit regression??? I am in marketing and am doing Conjoint Analysis. I was given some legacy WinBugs codes by my employer, but I am trying to switch to STAN.