> On Aug 15, 2016, at 7:41 PM, 'lizzy2016' via Stan users mailing list <
stan-...@googlegroups.com> wrote:
>
>
> I was wondering if someone could help me understand why applied uniformly distributed priors vs. default priors outputting drastic different results. Aren't default priors actually uniform distributions?
Stan's default priors are uniform on the declared constraint.
So if you declare a variable with <lower=0>, then the prior
is uniform on (0, infinity).
> Basically, i ran a linear regression via a simple Stan code as below. If commenting out the following two priors
> beta ~ uniform(-5000, 5000);
> sigma ~ uniform(0, 100);
>
> The result is similar as lm, as expected because MLE is equivalent to Bayesian + Uniformly distributed priors.
I don't know what you mean by "Bayesian" here. If you're
talking about posterior modes, then yes, if there are no
reparameterizations involved, then the posterior mode (often
called the max a posterior or "MAP" estimate) will be the
same as the maximum likelihood estimate (MLE).
But the MLE isn't a Bayesian estimate. We usually use the
posterior mean, not the posterior mode, because it minimizes
expected square error of the estimated parameters.
>
> However, if including them, the result from Stan is terrible; the chains don't even converge. By running lm, i know the coefficients are bounded by [-5000, 5000] and that's why i set the priors as beta ~ uniform(-5000, 5000);
Even if you know the MLE for the parameters falls in (-5000, 5000),
that doesn't mean putting a (-5000, 5000) prior won't affect the
posterior mean. You didn't show us how you're fitting here.
What was the MLE for the parameters? If it's near the boundaries
of (-5000, 5000), these uniform priors are going to have a big effect.
If you're just using Stan's MLE, then uniform priors won't have
much effect if the priors are away from the boundaries.
And yes, you want to constrain the parameters to <lower=-5000, upper=5000>
if you have a uniform(-5000, 5000) distribution, because Stan requires
the model to have support (non-zero density, finite log density) for
every value of the parameters meeting the constraints. If the parameters
are near the boundaries of (-5000, 5000), then you can run into
computational issues due to transforms.
But as Andrew says, this is probably not what you want to be doing anyway.
- Bob
>
> Can someone help? Thanks a lot.
>
> stanmodelcode = "
> data {
> int <lower=1> N;
> int <lower=1> K;
> matrix[N, K] X;
> vector[N] y;
> }
>
>
> parameters {
> vector[K] beta;
> real<lower=0> sigma;
> }
>
>
> model {
> vector[N] mu;
> mu <- X * beta;
>
> // beta ~ uniform(-5000, 5000);
> // sigma ~ uniform(0, 100);
>
>
> y~ normal(mu, sigma);
>
> }
>
> "
>