Darn, I was hoping that would fix it. I don’t see anything else wrong with the Stan program.
Is that the full output when you get error message? If there’s any more output that could help debug.
Also can you attach the actual file you’re using? Usually I prefer code in the post like you did, but in this case maybe there’s something weird with the file (I’ve seen that before).
Oh the problem isn’t the file but the call to stan(). Instead of the model_code argument you should use the file argument if you have a .stan file.
If using a string then model_code needs to be the full program as a string or the name of an object (not in quotes) to which the string has been assigned. But the recommended method is to use a file and avoid the model_code argument altogether.