Predicted Probabilities with posteriors in hierarchical multinomial (RStan)

I am a newbie in stan, recently ran my model successfully and got the posteriors for parameters. I have a multinomial model and now I want to extract predicted probabilities.

data {
  int<lower=1> D; // # of alternatives
  int<lower=0> L; // Participants
  int M[L]; // observed choice
  matrix[L,D] X; // observed outcome
  matrix[L,D] Z; // observed gain
parameters {
  real mu;
  real<lower=0> sigma;
  real<lower=0> lambda;
  real<lower=0> beta[L];

model {
  mu ~ normal(0,1);
  sigma ~ cauchy(0,1);
  lambda ~ lognormal(0,1);
  for (l in 1:L){
    beta[l] ~ lognormal(mu, sigma);
    M[l] ~ categorical_logit(to_vector(lambda*(Z[l])-beta[l]*(square(Z[l]-X[l]))));

For M[l] there are 6 (D) alternatives and I want to have predicted probabilities for each. I coudln’t find if there is a specified method for that with rstan and I couldn’t figure out how to do with posteriors for \mu, \sigma, \lambda and \beta.

I would appreciate any help and information on:

  1. Whether there is a certain method in rstan I can use to extract predicted probabiltiies?
  2. How can I calculate with posteriors?

There’s no automated utility for predictions. You can calculate the probabilities for M in the generated quantities block.

generated quantities {
  vector[D] probM[L];
  for (l in 1:L) {
    probM[l] = softmax(to_vector(lambda*(Z[l])-beta[l]*square(Z[l]-X[l])));

Thank you so much!