Hi everyone,
I am puzzled about the syntax in stan, and I am not sure if I can overcome this problem in any way.
I have to fit to some integer data a multinomial likelihood:
model {
for(y in 1:nyears){
data[,y] ~ multinomial(model[,y]);
}
}
On the left side of the tilde I can only enter an object of nature int. The problem is that I want to apply a transformation to my data within the parameter block in stan. The issue doing that is that stan does not allow to transform whatever you put in the data block. I thought a possible way to overcome the problem could have been defining an integer of the same dimension of data in the parameters block and fill it with the transformation of the data, as such:
transformed parameters {
int data_transformed[nlen,nyears];
scale the survey data
for (y in 1:nyears) {
for (l in 1:nlen) {
data_transformed[l,y] = data[l,y]/(sum(data[,y])*x;
}
}
}
The issue is that stan does not allow to define in into the transformed parameters block. I read that a possible trick was to put the operation into curly brackets, but doing so I am not able to call data_transformed in the model block.
It could be great if anybody had any idea! Thank you in advance.