Expected range constraint or identifier as part of top-level variable declaration

Hi, I am trying to run a simple hierarchical logistic regression model, but keep getting following error message:

"Syntax error in ‘string’, line 6, column 5 to column 6, parsing error:
Expected range constraint or identifier as part of top-level variable declaration."

I am not sure what the issue is, I thought that it may have something to do with the multiple indexing later in the model block and the variable subIdx in the data block. I tried applying different signatures (e.g. real subIdx[], or vector[] subIdx), but keep getting (different) error messages.

I would be really grateful if anyone could help me with this problem. Thank you!

data {
  int<lower=0> N; //number of subjects
  int<lower=0> Nx; //number of regressors
  int<lower=0> Ntotal;
  int[Ntotal]<lower=1>  subIdx; //array containing subject ID per trial
  real y[Ntotal];//LaterOptionChosen
  real x[Ntotal, Nx];

// The parameters accepted by the model. Our model
// accepts two parameters 'mu' and 'sigma'.
parameters {
  real beta0_mu; // intercept population level
  real<lower=0> beta0_sigma; //variance population level
  real xbeta_mu[Nx]; // regressor estimates
  real <lower=0> xbeta_sigma[Nx];
  real beta0_s[N];
  real xbeta_s[N, Nx];

model {
  beta0_mu ~ normal(0, 10000000); //prior intercept
  beta0_sigma  ~ uniform(0.0001, 100); //prior intercept error
  for (j in 1:Nx) {
    xbeta_mu[j]  ~ normal(0, 10000000); //prior slope
    xbeta_sigma[j] ~ uniform(0.0001, 100); //prior slope error
  for (n in 1:N) {
    beta0_s[n]  ~ normal(beta0_mu, beta0_sigma);
    for (j in 1:Nx) {
      xbeta_s[n, j]  ~ normal(xbeta_mu[j], xbeta_sigma[j]);
  for (i in 1:Ntotal) {
    real pr[i] = 1 / (1 + exp(-(beta0_s[subIdx[i]] + xbeta_s[subIdx[i], 1:Nx]*x[i, 1:Nx])));
    y[i] ~ dbern(pr[i]);


This line:

  int[Ntotal]<lower=1>  subIdx; //array containing subject ID per trial

has to be written as:

  int<lower=1>  subIdx[Ntotal]; //array containing subject ID per trial

Thank you for your response! I tried it, but get following message:

*"Error in stanc(file = file, model_code = model_code, model_name = model_name, : 0 Semantic error in ‘string’, line 39, column 48 to column 83: Ill-typed arguments supplied to infix operator . Available signatures: (int, int) => int (real, real) => real (row_vector, vector) => real (real, vector) => vector (vector, real) => vector (matrix, vector) => vector (real, row_vector) => row_vector (row_vector, real) => row_vector (row_vector, matrix) => row_vector (real, matrix) => matrix (vector, row_vector) => matrix (matrix, real) => matrix (matrix, matrix) => matrix Instead supplied arguments of incompatible type: real[], real[]."