On 1/18/14, 2:15 PM, Brian Lau wrote:
> I came across some confusing behavior in initialization (CmdStan 2.1.0, OSX 10.7.5, g++-4.2).
>
> Using the example bernoulli model from the manual (in src/models/basic_estimators)
>
> ./bernoulli sample save_warmup=1 data file=bernoulli.data.R
>
> Produces a random initial value for theta as expected by the default init=2
>
> ./bernoulli sample save_warmup=1 init=0 data file=bernoulli.data.R
>
> Results in the initial value for theta = 0.5. Shouldn't this be zero?
0.5 is correct. It's 0 on the *unconstrained* scale, which is then
inverse-logit transformed to (0,1) resulting in 0.5.
The [-2,2] uniform init is also on the unconstrained scale.
The reason we do this is that we're then guaranteed to get
a valid initialization point if the model's parameters are declared
with appropriate constraints (so support is over all valid variables).
The init files, on the other hand, are on the constrained scale,
and it's up to the user to make sure they satisfy the constraints.
> ./bernoulli sample save_warmup=1 init=init.R data file=bernoulli.data.R
>
> where init.R is a dump file with theta <- 0 produces the message "Rejecting user-specified initialization because of
> vanishing density." I guess this happens when an init exactly equals a bound? This call also returns an exit value of 0.
> Maybe it should return a more informative exit value, like when a initial value exceeds a bound. Changing init.R to
> theta <- 0.75 works and produces an expected initial value of 0.75.
>
> It got even stranger when I tested a model with a vector parameter. I tried a very simple regression (files attached)
> with the following:
>
> ./mlr sample save_warmup=1 init=0 data file=data.R
>
> which fails to produce initial values equal to zero.
>
> ./mlr sample save_warmup=1 init=init.R data file=data.R
>
> also usually does not produce the correct initial values. Close but not quite. I say usually because I've found that
> when sampling from more than one chain, I occasionally get a chain with exactly the correct initial conditions, for all
> parameters.
> I'm assuming the first row of samples in the csv files represent the initial conditions. Is this correct?
Yes, that's supposed to happen if save_warmup=1.
You've definitely tickled a bug here. If I do this:
~/temp2/lau$ ./mlr sample save_warmup=1 init=init.R data file=data.R
it saves the initialization as the first sample, whereas if I do this:
./mlr sample num_samples=100 num_warmup=100 save_warmup=1 init=init.R data file=data.R
it saves 200 iteration values, but the first one's not the initialization.
- Bob