Hi
I am just learning stan in order to use it to run mark-recapture models. I have had difficulty running the individual CJS model in the stan manual, which fails for me when it gets to beginning of the functions block:
functions {
int first_capture(int[] y_i) {
for (k in 1:size(y_i))
if (y_i[k])
return k;
return 0;
When I run the model it returns this error:
PARSER FAILED TO PARSE INPUT COMPLETELY
STOPPED AT LINE 10:
functions {
int first_capture(int[] y_i) {
for (k in 1:size(y_i))
if (y_i[k]) return k;
return 0;............*prints the rest of the stan code*
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
failed to parse Stan model 'individual_CJS' due to the above error.
}
I am running rstan, using R v. 4.0.3, and rstan v. 2.21.3. The data inputs for this model aren’t very clearly described, so I can’t tell if my inputs are wrong or something just isn’t working properly.
The collective CJS model on the same page works just fine with an input list like this:
history<-list(
history=c(12,3,2,19,13,2,1),
phi=c(.5,.5),
p=c(.5, .5, .5))
As far as I can tell, the individual CJS model should be able to run with a list like the following, but it just doesn’t work:
history.array<-list(y=matrix(c(1,0,0,1,0,0,0,0,1,0,0,1,
0,0,0,0,1,1,0,1,1,0,0,1,
1,1,0,0,1,1,0,0,0,0,0,0,
1,1,0,0,1,0,0,1), nrow=11),
T = as.integer(4),
I = as.integer(11),
phi = rep(.5,3),
p = rep(.5,4))
If anyone can tell me what is going sideways here, I’d really appreciate it.
thanks