Shape parameter is giving different results when compared to multiple variables

Hello everyone.

In my model, I’m getting different results when I use a shape parameter in the prior compared when I use 2 different variables.

Model 1

with pm.Model() as model1:

   mu_1 = pm.Uniform('mu_1', lower=0, upper=1)
   mu_coeff = pm.Normal('mu_coeff', 0, sigma=20, shape=3)
   sigma = pm.HalfNormal('sigma', sd=1, shape=2) 
   intercept = pm.Normal('intercept', 0, sigma=1, shape=2)

   y_1 = pm.Normal('bim_1', mu=mu_1, sigma=sigma[0],  observed=data[0])
   y_2 = pm.Normal('bim_2', mu = intercept[0] + mu_coeff[0]*mu_1, sigma=sigma[1],  observed=data[1])

For example, if I sample y_1 for this posterior is giving:

but when I don’t use the shape parameter and instead I use two distinct variables:

Model 2

with pm.Model() as model2:

  mu_1 = pm.Uniform('mu_1', lower=0, upper=1)
  mu_coeff = pm.Normal('mu_coeff', 0, sigma=20, shape=3)

  sigma1 = pm.HalfNormal('sigma_bim_1', sd=1)
  sigma2 = pm.HalfNormal('sigma_bim_2', sd=1)

  intercept = pm.Normal('intercept', 0, sigma=1, shape=3)

  bim_1 = pm.Normal('bim_1', mu=mu_1, sigma=sigma1,  observed=data[0])
  bim_2 = pm.Normal('bim_2', mu = intercept[0] + mu_coeff[0]*mu_1, sigma=sigma2,  observed=data[1])

I’m getting a much better fit.

I’m doing something wrong?

Thanks