stan-dev/stan — pull request #1185 by bob-carpenter (2014-12-22 22:06:23+00:00)
Title: Feature/issue 1099 init transform data

#### Summary:

* Initialize transformed data in the same way as transformed params (-max for integers, NaN for reals)
* Initialize generated quantities in the same way as transformed params (ditto)

#### Intended Effect:

See above. Makes behavior more consistent and makes it more likely that errors due to non-definition will be diagnosed.

#### How to Verify:

Run a model and see that it initializes properly at the start and in the generated quantities block. This one works for that purpose:

```
transformed data {
int n;
real x;
print("n=",n);
print("x=",x);
}
parameters {
real y;
}
model {
y ~ normal(0,1);
}
generated quantities {
int m;
real z;
print("m=", m, " z=", z);
}
```

I don't know how to make a real test out of this. Here's what the above now prints out, first for transformed data (printed before config is dumped for some reason):

```
~/temp2$ ./td sample
n=-2147483648
x=nan
```

and then later during sampling for the generated quantities:

```
Iteration: 2000 / 2000 [100%] (Sampling)
m=-2147483648 z=nan
```

#### Side Effects:

There will be different initializations, which could possibly change results for broken models. But previous behavior wasn't documented, so this isn't a backward compatibility issue.

Transformed data init will be a bit slower. Definitely won't be measurable as it'll only happen once.

Generated quantities will be a bit slower. Probably not enough to be measurable, but more of an impact than for transformed data.

#### Documentation:

Added documentation to the language section of the manual on validating constraints. The new behavior will probably more closely match user expectations because behavior will be consistent across transformed data, transformed parameters, and generated quantities.

#### Reviewer Suggestions:

Anyone.