# Jeffreys prior for a vector variable

I am trying to model the Jeffreys prior for error variance in a heteroscedastic ANOVA design in rstan.

That is to say, \pi(\mu,\sigma_1^2,\dotsb,\sigma_C^2)\varpropto\Pi_{i=1}^{C}\sigma_i^{-2}.

Is the following setting correct?

target += -2 * sum(log(sigma));


where the vector variable is declared as

vector<lower=0>[C] sigma;  // standard deviation of the error term


It seems not, because my current codes return an MCMC divergence warning.

Thank you for the kind comments.

Your variable sigma is a scale (\sigma), not a variance (\sigma^2), but otherwise corresponds to the math you wrote down.

We usually recommend at least weakly informative priors, so I’m not so familiar with these reference priors. According to the Wikipedia on Jeffrey’s priors, the prior on scale parameters \sigma should be \displaystyle {} \propto \sigma^{-1}.

Getting the math right doesn’t mean you won’t get divergences from difficult-to-sample posterior geometry using a direct parameterization. Especially if there’s a weak prior and not much data.

We can provide more detailed help if you include the entire model and data you’re trying to sample. For example, why isn’t \mu getting a prior and is there enough data to fix it? I realize from the Wikipedia page that’s the reference prior for the location of a normal distribution with a fixed scale. I don’t know what the joint reference prior is for location plus scales.

Thank you, Bob, for the kind comment.
According the Wikipedia you mentioned, “Similarly, the Jeffreys prior for \ln\sigma^2=2\ln\sigma is also uniform”. So, I don’t think the mathematical expression \pi(\mu,\sigma_1^2,\dotsb,\sigma_C^2)\propto\prod_{i=1}^C\sigma_i^{-2} is incorrect. The complete code and data can be found on my previous post in the Stan forum here.

The difference is whether the uniformity is over \sigma or \sigma^2. The density p(\sigma) \propto 1 / \sigma is uniform over \sigma whereas p(\sigma^2) \propto 1 / \sigma^2 is uniform over \sigma^2. The former is uniform over scales whereas the latter is uniform over variances.

I don’t know anything about Jeffrey’s priors, so this is just about densities.

Also, you have to be careful in that Stan applies its own Jacobian correction for variables declared with <lower = 0>. For complete control, you can define unconstrained parameters and constrain and adjust them yourself.