This is not a problem with Stan. The problem is in the posterior.
Bayesian posterior aren't just fuzzy maximum likelihood estimates.
They weigh the prior and the likelihood. Your likelihood and
improper flat prior are the problem, and you can see that analytically
without any software.
beta[, 6] is zero everywhere other than n in 26:30:
beta[1:25, 6] = 0
beta[31: , 6] = 0
And when beta[, 6] is equal to 1, all other predictors are 0:
beta[26:31, 1:5] = 0
beta[26:31, 6] = 1
And the relevant outcomes are within two standard deviations (sigma = 0.5)
of zero:
> y[26:30]
[1] 0.8223102 0.7249307 0.4358804 0.7082023 0.3269365
Here's where you run into trouble: the prior on beta is improper
and you have an exp() link function. Therefore, you get a posterior
with a very flat likelihood for beta[6] < 0. Because your prior
is improper, those combine to put most of your probability mass
on high negative values.
Stan can't sample effectively from very nearly improper posteriors,
and it shows its inability by providing divergence diagnostics and
R-hat values clearly indicating non-convergence.
Even if you add a normal(0, 5) prior for beta, it will pull the
posterior to the point where the true values are in the 95% posterior
intervals. But because the likelihood is relatively flat, the prior will
have a very strong effect.
- Bob
> To unsubscribe from this group and all its topics, send an email to
stan-users+...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.