I am receiving the following error when running the Stan program at the bottom of this post in RStan:
Syntax error in ‘string’, line 5, column 22 to column 23, parsing error:
Expected non-array type after array in return type
The error is due to the object returned from my call to the fill_0s()
function defined in the transformed parameters
block. However, I don’t know what is causing the error, since my function is supposed to take an array of integers as an input and output an array of integers…but the error tells me it’s expecting NOT to receive this. Any ideas on what I’m doing wrong?
data{
int x;
}
transformed data{
// defines: `fill_0s` function
// loops through a size x array of integers and replaces values with 0, returning
// an array of integers
array[x] int fill_0s(array[x] int in_array){
int z = size(in_array);
for (i in 1:z){
in_array[i] = 0;
}
return(in_array);
}
array[x] int new_array;
new_array = fill_0s(new_array);
}