Good night,

I am from Colombia and needing a few help with my code in Stan. I am making a ordered logistic model with not constant number of categories. Some of you could give me some ideas for making a model with a varible number of categories by item. For example: item 1 have 4 categories, item 2 have 5 categories, … .

In my code, i have a funtional code with the same number of categories boundaries.

I will be so gratedfull,

Sebastián

data{

int<lower=1> N; // number of answers

int<lower=10> N_fami; // number de entrepreneur

int<lower=2> N_item; // number de items

int<lower=2,upper=3> N_cat; // number of categories item

int<lower=1,upper=N_cat> y[N]; // respuestas; y[n], n-th respuesta

int<lower=1,upper=N_fami> famiempresas[N];// respuestas del empresario[n]

int<lower=1,upper=N_item> item[N]; // número de items [n]

}//end data

parameters{

vector[N_fami] theta; // latent traits of microempresarios

ordered[N_cat-1] beta[N_item];// coefficients of predictors (cut p)

real mu_beta; // mean of the beta-parameters: difficulty of the item

real<lower=0> sigma_beta; //sd of the prior distributions of category difficulty

real pho_theta; // parámetro de asimétria del trazo latente

vector<lower=0>[N_item] alpha;

}//end parameters

model{

theta ~ skew_normal(0,1, pho_theta);// latent traits

for(j in 1:N_item){

beta[j]~ normal(mu_beta,sigma_beta);// prior of the item parameters

alpha[j] ~ normal(0,1); // prior discriminación

}

mu_beta ~ normal(0,2); // hyper prior for mu_beta

sigma_beta ~ cauchy(0,2); // hyper prior for sigma_beta

pho_theta ~ normal(0,1); // hyper prior for theta, parámetro de asimétria.

//likelihood

for(n in 1:N){

y[n] ~ ordered_logistic(alpha[item[n]]*theta[famiempresas[n]],beta[item[n]]);

}

}//end model

generated quantities {

vector[N] log_lik;

for (n in 1: N){

log_lik[n] = ordered_logistic_log(y[n],alpha[item[n]]*theta[famiempresas[n]],beta[item[n]]);

}

}//generated quantities

The model

P[u_{ij}=g|\theta_j,\xi]=logit^{-1} (\eta_{g-1})- logit^{-1} (\eta_{g}) where, logit^{-1}(\eta_{g-1})= (1+e^{-\eta_{g-1}})^{-1}, \eta_{g_{-1}}=(\alpha_i*\theta_j-\alpha_i*\beta_{i,g-1}) and logit^{-1}{(\eta_g)= (1+e^{-\eta_g})^{-1}} \eta_g=(\alpha_i*\theta_j-\alpha_i*\beta_{i,g}).

P[u_{ij}=g|\theta_j,\xi]= \left\{ \begin{array}{lcc}
1-(1+e^{-\eta_{1}})^{-1} & si & g=1 \\
(1+e^{-\eta_{g-1}})^{-1}-(1+e^{-\eta_g})^{-1}& si & 1 < g < k \\
(1+e^{-\eta_{k-1}})^{-1} & si & g = k-1
\end{array}
\right.

\theta_j \sim SN(0, 1, \rho), \nonumber\\
\rho \sim N(0,1),\nonumber \\ \nonumber
\alpha_i \sim N(0,1),\\ \nonumber
\beta_{ig}\sim N(\mu_{beta_{ig}},\sigma_{beta_{ig}}),\\ \nonumber
\mu_{beta}\sim N (0,1),\\ \nonumber
\sigma_{beta}\sim Cauchy (0,2)