On 9/7/13 7:00 PM, Martin �m�ra wrote:
> Yes, I've tried using uniform prior for sigma1 (0,2) and sigma2 (0,50), but it doesn't help.
> Do you think LKJ parameterization would help? I'll try it tomorrow, seems complicated.
I don't think it'll help control the sampling. But you'll
want to do something like this for higher dimensions than 2.
I reparameterized your model with a uniform prior for scale
instead of your vague inverse gamma for precision.
I also rewrote it to be a bit more efficient. It may not be
ideal for pedagogical purposes --- we struggle with the balance
between writing clear and writing fast models (ideally, Stan would be
smart enough to turn the former into the latter!).
It looks like the model mixes well and produces posterior draws for
r (correlation) that look like the values I see in figure 5.4.
And it's recovering reasonable mu values. I'm not seeing the
wild multimodal posterior densities you plotted.
Where did your inputs come from and did they match the inputs
that generated fig 5.4 in the notes? From the text,
it looks like
sigmaerror = c(0.03,1)
was the input. But in your code, it was
sigmaerror = c(0.03,10).
Even if I use more error, I recover roughly the same values, though effective
sample size is quite a bit lower per iteration.
You also have this:
mu ~ normal(0,sqrt(1000));
which is an informative prior on the scale you're at,
because the posterior mean of mu[2] is 98, whereas sqrt(1000)
is only 32, and there are only 12 noisy data points!
For instance, changing it to
mu ~ normal(0,sqrt(10000));
raises the posterior mean estimate of mu[2] from 98 to 100.
This prior may also not be interacting well with the noise model that has
scale sd = 10 in the more extreme parameterization.
In general, it can be problematic when you're estimating values
near boundaries. What happens in Stan is that we logit transform
bounded values (and then scale and translate them). Values near
boundaries on (-1,1) represent logit values near -infinity or +infinity,
which can be difficult numerically.
Also, with the two different scales, Stan has to do more work.
Ideally, the data itself would be a bit more standardized.
> I'm actually doing it for EJ. I'm working on implementing all those models from the book.
:-) Small world, of course.
- Bob
P.S. I see you have kappa coefficients coming up next. I'd suggest
looking at something like Dawid and Skene's 1979 measurement error
model for data annotation in addition to kappa.