# When probability statement only includes parameters - use non-centered parameterisation

**URL:** <https://discourse.mc-stan.org/t/when-probability-statement-only-includes-parameters-use-non-centered-parameterisation/28049>\
**Category:** Modeling\
**Tags:** fitting-issues\
**Created:** [July 2, 2022, 2:36am UTC](https://discourse.mc-stan.org/t/when-probability-statement-only-includes-parameters-use-non-centered-parameterisation/28049 "2022-07-02T02:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stemangiola](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stemangiola/32/260_2.png) [@stemangiola](https://discourse.mc-stan.org/u/stemangiola)\
**Post date:** [July 2, 2022, 2:36am UTC](https://discourse.mc-stan.org/t/when-probability-statement-only-includes-parameters-use-non-centered-parameterisation/28049/1 "2022-07-02T02:36:33Z")

</div>

Hello,

I have a big hierarchical regression model. As it makes sense to see how it works without data, I did that. I could not manage to get a good mixing, so I simplified the model to detect the minimum pathology.

Why is a simple model like this not mix well? Play understand the two parameters will be correlated but I don’t see why they should not mix very well.

The weird mixing you see below gets worse as the model gets more complicated however the same mixing patterns remain. I suspect this is the underlying cause of the poor mixing of my model without the data.

Should all models work well without data to be declared as good models to start with?

```stan

parameters {
  real alpha; 
	real beta; 
}

model {
  beta ~ normal( alpha, 0.5);
	alpha ~ normal(0, 0.5);
}

```

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/3/34fd92d2a072dcf1bb54ed98941740903fb2fc12.jpeg)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/6/62faa47b41bf6890a931c56406eb837433f4f600.png)

---

<div class="post-metadata">

**Author:** ![stemangiola](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stemangiola/32/260_2.png) [@stemangiola](https://discourse.mc-stan.org/u/stemangiola)\
**Post date:** [July 2, 2022, 5:09am UTC](https://discourse.mc-stan.org/t/when-probability-statement-only-includes-parameters-use-non-centered-parameterisation/28049/2 "2022-07-02T05:09:05Z")

</div>

Worst still if one of the standard deviations is a parameter

```stan
parameters {
  real alpha; 
	real beta; 
	real<lower=0> phi;
}

model {
  beta ~ normal( alpha, phi);
  beta ~ student_t(3,0,1);
	alpha ~ normal(0, 0.5);
	
	phi ~ gamma(3,3);
}

```

```r
Warning: 76 of 4000 (2.0%) transitions ended with a divergence.
See https://mc-stan.org/misc/warnings for details.

```

Fit with `cmdstanr`

---

<div class="post-metadata">

**Author:** ![stemangiola](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stemangiola/32/260_2.png) [@stemangiola](https://discourse.mc-stan.org/u/stemangiola)\
**Post date:** [July 2, 2022, 5:25am UTC](https://discourse.mc-stan.org/t/when-probability-statement-only-includes-parameters-use-non-centered-parameterisation/28049/3 "2022-07-02T05:25:18Z")

</div>

> **[Stan User’s Guide](https://mc-stan.org/docs/2_18/stan-users-guide/reparameterization-section.html)**
>
> Stan user’s guide with examples and programming techniques.

The non-centered parameterization is crucial, should have studies the manual better.

```stan
parameters {
  real alpha; // Root
  real<lower=0> phi;
  real<offset = alpha, multiplier = phi> beta; // Root
}

model {
	
  beta ~ normal( alpha, phi);
	alpha ~ normal(0, 0.5);
	phi ~ gamma(3,3);
}

```
