Parser requires integer length for vector after supplying integer length

I want to declare a one-dimension vector of length N called fd at the top of model block.
Error message was “PARSER EXPECTED: vector length declaration: integer expression in square brackets”, which was not reproduced in the code simulation here.
I have confirmed that N is an integer declared in the data block(first line). I did not see conflict in variable names. N has been used as vector length in previous declarations without any problem.

  data{
    int<lower=0> N;               // number of observation
    int<lower=0> S;               // number of studies
    int<lower=0> Gmax;            // largest number of dose groups
    int<lower=0,upper=Gmax> G[S]; // number of dose groups

    vector[N] ymeanL;             // ymean log
    vector[N] ysdL;               // ysd log
    vector<lower=0>[N] Nsub;      // number of subjects
    row_vector[N] dose;           // dose
  }
  
  transformed data{
    row_vector[N] dosed;          // transformed dose
    dosed = ( dose - min(dose) ) / ( max(dose) - min(dose) );
  }
  
  parameters{
    real<lower=0> sigma;
    real<lower=0> c;
    real<lower=1,upper=15> g;
    
    vector<lower=0>[S] a;
    vector<lower=0>[S] b;
    
    real mu_a;
    real<lower=0> sigma_a;
    
    real mu_b;
    real<lower=0> sigma_b;
  }
  
  model{
    vector<lower=0>[N] fd;              
    int pos;              

    
    // Priors
    sigma ~ uniform(0,10);
    mu_a ~ uniform(-2,2);
    sigma_a ~ uniform(0,2);
    mu_b ~ uniform(-3,3);
    sigma_b ~ uniform(0,2);
    c ~ uniform(0,15);
    g ~ uniform(1,15);
    
    // Parameters
    a ~ lognormal(mu_a,sigma_a);
    b ~ lognormal(mu_b,sigma_b);
    
    // Hill equation
    pos = 1;                          
    for(s in 1:S){
      for(gg in pos:(pos+G[s]-1)){
        fd[gg] = a[s] + ( b[s] * dosed[gg]^g ) / ( c^g + dosed[gg]^g );
      }
      pos = pos + G[s];
    }

    // Likelihood
    target += -( Nsub/2*log(sigma^2) +  ( Nsub*(ymeanL-log(fd))^2 + (Nsub-1)*ysdL^2 ) /
    (2*sigma^2) );
  }


I believe this is because you’ve declared the vector with a constraint:

vector<lower=0>[N] fd; 

Constraints aren’t used in the model block

2 Likes

Andrew thank you so much!
After removing the constraint, this declaration was recognized. Your suggestion totally solved my problem.

Since constraints aren’t used in the model block, I will look for other ways to set constraints for this variable. Thank you again!