On 5/8/12 7:09 PM, Marcus Brubaker wrote:
> First, the way chains are initialized right now is pretty inflexible. Basically, the random initialization is uniform
> on [-1,1] (or maybe [0,1]) which isn't ideal for some models and may not be well dispersed for Rhat statistiics with
> multiple chains.
Right now, it's uniform on (-2,2).
(line 311 of gm/command.hpp now that
I looked it up).
> Currently the only way around this I've found is to construct initialization files by hand.
That's right. The initial values are
on the model's scale, not the transformed
unconstrained scale.
> For 1.0
> it would be nice if the initialization was a little better dispersed and maybe a bit more flexible. E.G., make the
> random initialization Normal(0,sigma) where sigma could be set from the command line. Even better would be
> Student-t(0,sigma,d) but that's minor.
Either a normal or Student-t would be just as easy
as the uniform.
What I'm worried about is that with very diffuse priors,
the initial values are going to be too far out. For instance,
someone using a uniform(0,1000) parameter on a scale
parameter would get initial values around 500!
> Ideally, maybe for 2.0, there would be an optional way to specify in the model
> file an initialization section which could do data and model specific initialization.
I like that idea.
It should be pretty easy to code with just another
block I would run like the parameters block already.
I'll have to think a bit about constraints and error
checking. Presumably it would also be on the model's
scale, not the unconstrained scale.
What we will need is all the random variate generators.
We also need those for the generated quantities block,
because Andrew wants to use it for "forward sampling"
in a model checking context (it's forward in the
directed graphical model sense of taking fixed values
of parameters from the root down to some point and
then randomly generating the rest -- you don't need
any fancy computation, just generators from the basic
distributions).
One issue is what the syntax should be. Andrew was
thinking of overloading the sampling ~ to work as
a random variate generator. So if you wrote
for (n in 1:N)
beta[n] ~ normal(0,10);
in the derived quantities block (or the parameter
initialization block), you'd get something equivalent
to
beta[n] <- random_normal(0,10);
> The other thing was an easy way to restart chains. Last I checked this wasn't supported but seems like a pretty
> important thing to be able to do. Even just adding an ability to output a text file with the last sample which was in
> the format of an initialization file would be a pretty good improvement.
That's already on the to-do list. It's still not
supported. I struggled with the I/O format. I figured
the dump format for input is too structured for most
people's output needs. But it's not hard to dump our
variables in that format, though so far there's only
a reader, not a writer for the dump format.
It could also stand to be made a bit more robust to
the crazy behavior of R (writing 2:3 instead of c(2,3)
if it can for dimensions, for instance).
> Anyway, those are relatively small in the grand scheme of things but would definitely be noticed by people attempting to
> use it.
Indeed. Thanks for the suggestions.
- Bob