PMF for predictions in ordered logistic model

Hello - I have a simple ordered logistic model and I’m predicting outcomes with the y_tilda below. I’d like to get the actual probability for each discrete outcome. When I plot the fit, I’m getting continuous density functions for the outcome. Results look great, but how do I get the PMF or actual discrete samples for the predictions y_tilda?

Thank you!!! -Jamie

code = '''
data {
  int<lower=2> K;                            // number of discrete outcomes
  int<lower=0> N;                            // samples
  int<lower=1> D;                             // data row dim
  int<lower=1> M;                             // number of predictions
  int<lower=1,upper=K> y[N];           // outcome
  row_vector[D] x[N];                  // data - record and last six for each boxer
  row_vector[D] xx[M];                  // data to predict on boxers
parameters {
  vector[D] beta;                     
  ordered[K-1] c;
model {
  for (n in 1:N)
    y[n] ~ ordered_logistic(x[n] * beta, c);
generated quantities {
  int<lower=1, upper=K> y_tilda[M];
  for (j in 1:M)
    y_tilda[j] = ordered_logistic_rng(xx[j] * beta, c);
stan_model = StanModel(model_code=code);

Please disregard… fit.export() is what I was looking for!!!

Awesome. Want to mark your reply as solving the problem? It’ll make it easier to see that this thread is complete.

(I can do it, but it’ll help when the community picks up these forum tools.)

Btw, for code blocks, use triple back ticks for fences (```) and single back ticks for inline code, e.g. `fit.export()` renders as fit.export().

gotcha… and will do. thank you!!

1 Like