> On Feb 20, 2017, at 7:04 AM, Andrew Gelman <
Gel...@stat.columbia.edu> wrote:
>
> Hi, I have a few questions/requests which are relevant for my applied work, and also for the new book with Jennifer.
>
> 1. Random-variable objects.
>
> After I've fit a model, I'll often want to do things with the parameters. For example, MRP. I do it in R. But it's awkward to work with posterior simulations in R for all the usual reasons: I'm continually having to wrestle with array algebra, having to decide what to do with indexes. For example, if I want to draw from normal(X*beta, sigma), I need to either figure out some slick "apply" thing or else loop on simulation draws and use indexing like beta[s,] and sigma[s], which also required me first assigning a blank object to whatever I'm creating. Yes, it can be done, but it turns simple statistical manipulations, which would be short one-liners with random variable objects, into mini-programs. This is, I think, contrary to the spirit both of R and of probabilistic programming.
To code this up and R, you'd need to reimplement all the functions you want
to work with random variable data types. This is what that package with Jouni.
> In Stan, we can work with random variables in the generated quantities block. But right now you can't run a generated quantities block on its own. I think this should change: we should allow the user to pass a stanfit object (or whatever this is called outside of R, umm, I guess it's just "the output from a fitted Stan model") and run a generated quantities block all on its own.
Yes. Everyone agrees this is a good feature. We'll add it
pretty soon, but not in 2.15---that's going to be just getting
the refactor into production.
Just need to get the round trip of converting outputs into
initializations.
...
> 2. Stan output.
>
> Currently, in addition to Rhat and n_eff, we report posterior mean, sd, and a bunch of quantiles. I'm wondering if we should follow the model of rstanarm and replace mean and sd by median and mad_sd (that's the median absolute deviation from the median, multiplied by a scaling factor so that it is equivalent to the sd for the case of the normal distribution).
That sounds too complicated to me. I always think of these things
in terms of how we want to document it.
> These have the advantage that they always exist (so will work, for example, with the Cauchy distribution), also I think they're closer to what users should really want in most applications. Similarly, we'd replace se_mean by mad_se which is just mad_sd/sqrt(n_eff). Then for the quantiles, now we report 2.5%, 25%, 50%, 75%, 97.5%. OK, we don't need 50% anymore. I'd recommend removing 2.5% and 97.5% too (or maybe not, I'm not quite sure; on one hand, focusing on these intervals is bad practice, and these tail values have lots of simulation noise; on the other, it can be good for people to see some wide uncertainty bounds).
>
> So here's the new output:
>
> median mad_sd 25% 75% n_eff mad_se Rhat
Are you going to stop using means altogether? I think there'd
be a user revolt if we don't have mean and se_mean (though I'll
admit users get confused between se_mean and posterior sd).
> You can see that I changed the order a bit. I find se_mean (or, equivalently, mad_se) a bit difficult to explain.
> I end up just saying it's sd/sqrt(n_eff)
That seems pretty easy to me.
> (or mad_sd/sqrt(n_eff), but, if so, it makes sense for it to appear _after_ n_eff in the table. Finally, I kept Rhat at the end because it's convenient to scan the output and look at R_hat.
I don't mind the order.
> 3. Pulling out parameter estimates:
I'll leave this up to the RStan devs. I don't have problems with
this the way things are, but can see how it could be streamlined
for some common operations.
- Bob