Having this issue when trying to run an ordered_logistic model for a latent variable with 7 ordered variables with 5 levels. In the past I’ve put the linear component in the parameter block but here I put it in the model block. I get the following error:

Too many indexes, expression dimensions=0, indexes found=1
error in ‘model15e8d7e806868_interpersonal_behavior_model’ at line 32, column 49

Sorry, your question fell through a bit. Did you manage to resolve this?

Also note that the error involves indexing of a data element, so we can’t really help you unless you post the full model (it is generally better to always provide the full model - if it is very big, just attach it as a file)

Yeah I haven’t been able to solve this unfortunately. Given that it is an indexing error, I think it may have something to do with my data. The error is being brought up within the item_k5 indexing and this is an integer vector that is simply 1:7 repeating for how many variables I am feeding into the latent model. It is of type integer within R and is the same length and type of n_k5 (number of non-missing item observations). I did a different model with different data in a similar format and had no issues with this way of indexing through and ordered variable like this. Thanks for your help!

data {
int<lower=0> n; //number of rows
int<lower=0> k5; //number of variables
int<lower=0> n_k5; //number of non-missing item-observations
int<lower=0> id_k5; //identifier for the individual-item observation
int<lower=0> item_k5; //indicates which item is being dealt with
int<lower=1, upper=5> y_k5[n_k5]; //observations are ordered in a way that indicates higher values as more cautious interpersonal behavior
}
parameters {
real<lower=0> beta_k5[k5];
ordered[4] c_k5;
vector[n] theta;
}
transformed parameters{
real xb_k5[n_k5];
for(i in 1:n_k5){
xb_k5[i] = beta_k5[item_k5[i]] * theta[id_k5[i]];
}
}
model{
for(j in 1:c_k5){
c_k5[j,1] ~ normal(0,5); //priors for 5cat
c_k5[j,2] ~ normal(0,5);
c_k5[j,3] ~ normal(0,5);
c_k5[j,4] ~ normal(0,5);
}
theta ~ normal(0,1); //prior on latent variable
beta_k5 ~ normal(0,1); //priors on beta values
//linear component
y_k5 ~ ordered_logistic(xb_k5, c_k5);
}

Then you need to declare item_k5 (and likely other variables) as an array, i.e.:

int<lower=1, upper=k5> item_k5[n];

I’ve also added bounds - those are optional but make it easier to catch errors - if you want to use item_k5 as index into beta_k5, those bounds need to hold.