# Covariance matrix

Hi,
I would be interested in modelling the covariance matrix of the fixed effects. So far, I’ve been able to model the correlation matrix of the random effects and used the Cholesky factorization to do so. I would like to do something similar for the covariance matrix of the fixed effects. And what kind of priors should I use. Any help would be greatly appreciated! Here is the code:

``````parameters{
vector beta;//Fixed-effects when no moderation
// vector beta;// Fixed-effects when moderation
real<lower=0> sigma_em; // Residual std (Mediator)
real<lower=0> sigma_ey; // Residual std (Outcome)
vector<lower=0> sigma_u; // Random effects' standard deviations when no moderation
//vector<lower=0> sigma_u;  // Random effects' standard deviations when moderation
cholesky_factor_corr L_u;//Declare L_u to be the Choleski factor of a 5X5 correlation matrix (no moderation)
//cholesky_factor_corr L_u;//Declare L_u to be the Choleski factor of a 9X9 correlation matrix (moderation)
matrix[5,J] z_u; // Random effects' matrix (no moderation)
//matrix[9,J] z_u; // Random effects' matrix (moderation)
}

/*Transformed Parameter Block:
Transforms of the parameters before computing the likelihood*/
transformed parameters {
matrix[5,J] u; //no moderation
//matrix[9,J] u; //moderation
/*The Cholesky factor is first multipled by the diagonal matrix formed
by the vector of the random effect variances "sigma_u",
and then is multiplied with the random effects' matrix "z_u",
to obtain a random effects' matrix with the intended correlations.*/
u = diag_pre_multiply(sigma_u, L_u) * z_u;
}
}
``````

Your `sigma_u` parameter combines with the `L_u` parameter to determine the covariance matrix. If you are already modelling effects on these quantities, you are already modelling effects on the covariance matrix.

So you’re saying multiplying both of those parameters will give me the covariance matrix of the fixed effects?

Yup!

Ok, I’m a little confused here. I kind of understand that if you multiply sigma_u and L_u, you’ll get back a covariance matrix. That is, I’m not sure how to have a different matrix for the fixed effects and the random effects.
Thanks.