20.2 Special-case distribution issues
Pedantic mode checks for some specific uses of distributions that may indicate a statistical mistake:
20.2.1 Uniform distributions
Any use of uniform distribution generates a warning, except when the variate parameter’s declared upper
and lower
bounds exactly match the uniform distribution bounds. In general, assigning a parameter a uniform distribution can create non-differentiable boundary conditions and is not recommended.
For example, consider the following program.
parameters {
real a;
real<lower=0, upper=1> b;
}
model {
a ~ uniform(0, 1);
b ~ uniform(0, 1);
}
a
is assigned a uniform distribution that doesn’t match its constraints.
Pedantic mode produces the following warning.
Warning at 'uniform-warn.stan', line 6, column 2 to column 20:
Parameter a is given a uniform distribution. The uniform distribution is
not recommended, for two reasons: (a) Except when there are logical or
physical constraints, it is very unusual for you to be sure that a
parameter will fall inside a specified range, and (b) The infinite gradient
induced by a uniform density can cause difficulties for Stan's sampling
algorithm. As a consequence, we recommend soft constraints rather than hard
constraints; for example, instead of giving an elasticity parameter a
uniform(0,1) distribution, try normal(0.5,0.5).
20.2.2 (Inverse-) Gamma distributions
Gamma distributions are sometimes used as an attempt to assign an improper prior to a parameter. Pedantic mode gives a warning when the Gamma arguments indicate that this may be the case.
20.2.3 lkj_corr distribution
Any use of the lkj_corr
distribution generates a warning that suggests using the Cholesky variant instead. See https://mc-stan.org/docs/functions-reference/correlation_matrix_distributions.html#lkj-correlation for details.