On 1/1/14, 9:31 PM, Filip Krynicki wrote:
> Thanks for all the help, the response has been well beyond what I could have hoped.
We take bugs seriously, and diagnosing them often involves
us having to dive into the particulars of the models.
We're also interested in bringing more people up to speed in
Bayesian modeling and want to understand where new users have
problems.
> I have a very naive question. How
> would I specify a prior on the alpha and beta parameters? My understanding is that the lower and upper keywords specify
> hard constraints (or as close as is allowed given numerical precision issues).
They restrict alpha and beta to the constrained ranges (both > 0 in this case,
modulo arithmetic underflow, which can make them 0). Then you get a uniform
prior over that range, which is improper in this case because
INTEGRAL_0^infinity const dx = infinity
> Do I specify a prior by sampling the
> alpha and beta parameters from a distribution defined by a hyperparameter?
Yes, but the sampling statements don't actually do sampling. So
you don't actually sample alpha and beta from their priors, per se,
though that's the generative story of your model. In Stan, sampling
statements just add terms to the log probability function.
> I'm looking through the manual for any mention of priors and coming up with nothing.
They're all over the place in the manual. In the
very first example there's a beta prior on theta.
We're assuming a fair degree of background in Bayesian
stats, though there's a chapter near the end of the manual
on Bayesian data analysis that recapitulates the initial
chapter(s) of Gelman et al.'s book of the same name.
> My thinking would be (using a
> normal prior for both parameters for simplicity's sake):
>
> data {
> ...
> real prior_mu;
> real prior_sigma;
> }
>
> parameters {
> real alpha;
> real beta;
> }
>
> model {
> alpha ~ normal(prior_mu, prior_sigma)
> beta ~ normal(prior_mu, prior_sigma)
> for (i in 1:N) {
> y[i] ~ beta(alpha, beta);
> }
> }
>
> This model compiles and runs but I have little confidence that it's doing what I think it is from a theoretical standpoint.
This is OK, theoretically at least. The prior is
technically a normal truncated to the constrained values.
A more typical prior might be an exponential or lognormal, if you
put it direclty on alpha and beta. But it's more typical to do
what we discuss in section 17.1 of the manual, which specifically discusses
priors for the beta distribution in terms of a reparameterization
in terms of the mean (alpha / (alpha + beta)) and
total prior count (alpha + beta). There we use a Pareto prior following
Gelman et al.'s Bayesian Data Analysis, but a lognormal or
exponential (or more geneally gamma) would also make sense.
- Bob
>
>
> On Wed, Jan 1, 2014 at 2:48 PM, Bob Carpenter <
ca...@alias-i.com <mailto:
ca...@alias-i.com>> wrote:
>
> On 1/1/14, 12:53 AM, Fil Krynicki wrote:> The exception is causing the code to die, which is the problem. The exact
> exception is:
>
> >
> > File "/usr/lib/python3.3/site-__packages/pystan/api.py", line 366, in stan
> > n_jobs=n_jobs, **kwargs)
> > File "/usr/lib/python3.3/site-__packages/pystan/model.py", line 679, in sampling
> > ret_and_samples = _map_parallel(call_sampler___star, call_sampler_args, n_jobs)
> > File "/usr/lib/python3.3/site-__packages/pystan/model.py", line 81, in _map_parallel
> > return list(mymap(function, args))
> > File "/usr/lib/python3.3/__multiprocessing/pool.py", line 228, in map
> > return self._map_async(func, iterable, mapstar, chunksize).get()
> > File "/usr/lib/python3.3/__multiprocessing/pool.py", line 564, in get
> > raise self._value
> > OverflowError: Error in function boost::math::digamma<d>(d): numeric overflow
>
>
> I just verified that this is a PyStan-specific problem
> and opened this issue to track its being fixed:
>
>
https://github.com/stan-dev/__pystan/issues/53 <
https://github.com/stan-dev/pystan/issues/53>
> To unsubscribe from this topic, visit
https://groups.google.com/d/__topic/stan-users/ia-k26aucy0/__unsubscribe
> <
https://groups.google.com/d/topic/stan-users/ia-k26aucy0/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to stan-users+unsubscribe@__
googlegroups.com
> <mailto:
stan-users%2Bunsu...@googlegroups.com>.
> For more options, visit
https://groups.google.com/__groups/opt_out <
https://groups.google.com/groups/opt_out>.
>
>
> --
> 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.