# For loop issus caused by unbalanced group number

Hello,

I have a question about for loop. Since I have different area s and for each area, it has different amount of residents n_s. So I record the starting number and ending number of each area into two separate vector. And call them in the for loop.

The for loop structure like:

``````for (k in 1:s) {
for (j in 1:n_s){
int index = k*n_s-n_s+j;
# compute the posterior
``````

So mine is:

``````for (k in 1:s) {
int start_point = starting[k];
int end_point = ending[k];
for (j in start_point:end_point){
int index = j;
# compute the posterior
``````

And for starting and ending:

``````data {
int s;
int N;
vector[s] starting;
vector[s] ending;
}
``````

I receive the error message as:

``````SYNTAX ERROR, MESSAGE(S) FROM PARSER:

variable definition base type mismatch, variable declared as base type: int variable definition has base: real  error in 'model33908d47a8_tweedie' at line 62, column 37
-------------------------------------------------
60: 	// likilihood of tweedie distribution
61: 	for (k in 1:s) {
62: 		int start_point = starting[k];
^
63: 		int end_point = ending[k];
-------------------------------------------------

Error in stanc(file = file, model_code = model_code, model_name = model_name,  :
failed to parse Stan model 'tweedie' due to the above error.
In readLines(file, warn = TRUE) :
incomplete final line found on
``````

What should I do to solve this problem? Thank you very much for your help in advance.

With appreciation,

Tairan

Both `starting` and `ending` should be declared as integer arrays in the data block, as in

``````data {
int s;
int N;
int starting[s];
int ending[s];
}
``````

But trying to do a Tweedie likelihood with an unknown shape parameter is going to be painful.

Thank you very much for your help, Ben. The reason why I made this mistake is because I didn’t distinguish the vector of real and the vector of integers.

That is my research topic. So I can’t find any other way out. I have to work on it…= = So far not that bad.