# Does uneven pairsplot density indicate reparameterization?

Scale parameter (\sigma in stan manual) seems to impose strong bound on the Weibull distribution random variable; which led to the following parisplot of length_GP_engine and length_engine_scale. (green dot: divergence)

1. Does this pairsplot indicate the need for reparameterization? If so, what could be the reason? (e.g. does uneven density causes pathology in sampling geometry?)
2. Apart from its need, is the following the right parameterization? Unlike the reparameterization example of normal distribution in stan manual, I am not sure scale parameter could be linearly multiplied for Weibull distribution.

### original code

parameters{
...
real<lower=0> length_GP_engine;
real <lower = 0> length_engine_scale;
}

transformed parameters{
...
}

model {
vector[N] obs_mu;
for (n in 1:N) {
obs_mu[n] = mu
+ age_re[age_ind[n]]                                 //fixed effects
+ engine_re[ship_engine_ind[ship_ind[n]]]
+ ship_re[ship_ind[n]]
+ GP_engine[age_ind[n],ship_engine_ind[ship_ind[n]]] //f_engine
+ GP_ship[age_ind[n],ship_ind[n]];                   //f_ship
}
y ~ normal(obs_mu, sigma_error_ship);

to_vector(GP_engine_std) ~ normal(0, 1);
to_vector(GP_ship_std) ~ normal(0, 1);
age_std ~ normal(0, 1);
ship_std ~ normal(0, 1);
engine_std ~ normal(0, 1);
mu ~ normal(.5, .5);
tot_var ~ gamma(3, 3);
length_engine_scale ~ normal(3, 1);
length_ship_scale ~ normal(3, 1);
length_engine_shape ~ normal(20, 10);
length_ship_shape ~ normal(20, 10);
length_GP_engine ~ weibull(length_engine_shape, length_engine_scale);
length_GP_ship~ weibull(length_ship_shape, length_ship_scale);
}


### reparameterized

parameters{
real <lower = 0> eta;
real <lower = 0> length_engine_scale_s;
real <lower = 0> length_GP_engine_s;

}
transformed parameters{
real length_engine_scale = length_engine_scale_s * eta;
real length_GP_engine = length_engine_scale * length_GP_engine_s;
}

model{
length_engine_scale_s ~ std_normal();
length_GP_engine_s ~ weibull(length_engine_shape,1);
}


2 Likes

Hi, sorry we took so long to get to your inquiry.

1. Indeed the pairs plot looks fishy and might be a cause for pathological geometry. Indeed “uneven” density can be problematic - see Mike’s case study for a more in-depth description, if you haven’t already (https://betanalpha.github.io/assets/case_studies/identifiability.html)

2. I’ve found a slightly obscure reference that has a formula for scaling the Weibull (http://www.math.wm.edu/~leemis/chart/UDR/PDFs/WeibullS.pdf). If I understand it correctly their parametrization is a bit different - they use \alpha, \beta and I think (please check my calculations) that it relates to Stan’s parameterization (I’ll note it as \alpha_{stan}, \sigma) so that:

\alpha = \sigma^{\alpha_{stan}} \\ \beta = \alpha_{stan}

They then show that if Y \sim \mathrm{Weibull}(\alpha, \beta) and Y = kX we have Y \sim \mathrm{Weibull}(\alpha k ^ \beta, \beta)

Transforming for the Stan parametrization we get Y \sim \mathrm{Weibull_{stan}}(\alpha_{stan}, k\sigma). So I think you should be safe scaling your Weibull (but please, check my calculations) and I would expect it to help - at least with this part of the model.

Best of luck with your model!
(also, I enjoyed your StanCon presentation, cool work)

2 Likes