You need the Jacobian of the f:R^2 -> R^2 function
f(alpha, beta) = sqrt(alpha / beta^2), (alpha - 1) / beta
if you're going to declare alpha and beta as parameters and
put a prior on sqrt(alpha / beta^2) and (alpha - 1) / beta.
I'd also recommend sqrt(alpha) / beta as it does less arithmetic
and should also be more stable for small beta.
Alternatively, you can declare a parameter
vector[N] sqrt_alpha_over_beta;
and define
sqrt_alpha_over_beta ~ ...
and then derive the inverse of f to get alpha and beta back.
Then you won't need a Jacobian as you're putting the distribution
right on the parameter.
- Bob
> On Mar 31, 2017, at 12:28 AM, Luke <
mangiol...@gmail.com> wrote:
>
> Hello, I'm loving Stan!
>
> I have a question on jacobians within Stan.
>
> A pattern is emerging on the sd sqrt(alpha/beta^2) and mode (alpha-1)/beta of a gamma distributed parameter.
>
>
>
>
>
>
>
> Now I can reparametrize the gamma distribution for mode and sd but then I have to link mode and sd in, for example:
>
> sd[n] ~ normal( ang_coeff * mode, sigma[n] ); equal to
>
> -----------------------------------------------------------------------------------------------
> sqrt(alpha[n]/beta[n]^2) ~ normal(ang_coeff * (alpha[n]-1)/beta[n], sigma);
> -----------------------------------------------------------------------------------------------
>
> if alpha and beta are vectors[N] how can adjust with the jacobian?
>
>
> P.S. The plot above in terms of pure alpha and beta is
>
>
>
>
>
>
> Thanks
>
>
>
> --
> 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.
> To post to this group, send email to
stan-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.