# LKJCholeskyCov with different standard deviation distributions

Hi!

I am trying to implement a model with a Multivariate Normal likelihood and I am estimating the covariance matrix using the LKJCholeskyCov prior. However, I would like to define a different distribution for each one of the standard deviations. I read in the documentation that the `sd_dist` parameter must be a positive scalar or vector distribution for the standard deviations. So, I am defining a different distribution for each one and I am combining them using `at.stack`.

Here is the code:

``````with pm.Model() as model:
sigmas_dists= [ pm.InverseGamma.dist(alpha= 40, beta=80), pm.InverseGamma.dist(alpha= 100, beta=500) ]
stds = at.stack( sigmas_dists )

packed_L = pm.LKJCholeskyCov('packed_L', n=2, eta=2., sd_dist= stds , compute_corr=False)
L = pm.expand_packed_triangular(2, packed_L)
cov = L.dot(L.T)

...
``````

But I am getting the following error

``````TypeError: sd_dist must be a scalar or vector distribution variable
``````

What am I doing wrong?

Thank you in advance!

Try

``````stds= pm.InverseGamma.dist(alpha= [40, 100], beta=[80, 500])

``````
1 Like

It works! Thanks!

This works if want do define the same type of distribution for the standard deviations. How do I define the `LKJCholeskyCov` input if I want a different type of distribution for each sigma?

Here is an example:

``````with pm.Model() as model:
sigmas_dists= [ pm.InverseGamma.dist(alpha= 40, beta=80), pm.HalfNormal.dist(sigma = 5) ]
stds = at.stack( sigmas_dists )

packed_L = pm.LKJCholeskyCov('packed_L', n=2, eta=2., sd_dist= stds , compute_corr=False)
L = pm.expand_packed_triangular(2, packed_L)
cov = L.dot(L.T)

...
``````

If I do this, I get the following error

``````TypeError: sd_dist must be a scalar or vector distribution variable
``````

How can I implement this?

That is currently not allowed, because PyMC needs to be able to resize the `sd_dist` and evaluate it’s logp directly. If you were to pass a stack of distributions as the `sd_dist`, PyMC would not know how to do either of these two things.

1 Like