The problem is this:
parameters {
vector [N] u;
...
model {
u ~ gamma (0.001, 0.001);
...
You need to constrain the variable u to be positive because
gamma() only has support on (0,inf).
And following Andrew, I'll beep at the extra spaces
before "[" and "(". It makes the programs hard to read
because it violates standard formatting conventions. To me,
i t i s l i k e w r i t i n g t e x t l i k e t h i s .
We seem to get a lot of creative spacing from users in Stan,
some of it derived from R's unusual conventions, such as
return(x) vs. return x
if(foo) vs. if (foo)
line breaks to denote ends of statements vs. semicolons
I find the ones on the left hard to read --- every other language
I know conventionally uses the forms on the right (other than
Python, which uses spaces and line breaks; Lisp and its descendants
where it's all parens, and make, which uses tabs).
- Bob