# Making variance terms equal in mixture of gaussian example

I am trying to fit a 2D multivariate mixture of gaussian model where I would like to set the variances of the covariance terms to be equal. Is there a way of explicitly doing that?

Currently I just ask that sigma_1[k] ~ cauchy(0, 5);

mixture_model = '
data {
int D; //number of dimensions
int K; //number of gaussians
int N; //number of data

vector[D] pheno1[N]; //data

}

parameters {
simplex[K] theta; //mixing proportions
vector<lower=0>[D] sigma_1[K];
ordered[D] mu_1[K]; //mixture component means
cholesky_factor_corr[D] L_1[K]; //cholesky factor of covariance
}

model {
real ps[K];

for(k in 1:K){
mu_1[k] ~ normal(0,.5);
sigma_1[k] ~ cauchy(0, 5);
L_1[k] ~ lkj_corr_cholesky(4);
}

for (n in 1:N){
for (k in 1:K){
ps[k] = log(theta[k])+multi_normal_cholesky_lpdf(pheno1[n] | mu_1[k], diag_pre_multiply(sigma_1[k], L_1[k]));
}
target += log_sum_exp(ps);
}

}

generated quantities {
matrix[D,D] Omega[K];

Omega <- multiply_lower_tri_self_transpose(L_1);
Omega <- multiply_lower_tri_self_transpose(L_1);
}

Do you mean make them independent of the mixture? Just declare whichever thing you only want one of as a single parameter instead of an array.

Maybe something like:

``````parameters {
vector<lower=0>[D] sigma_1;
...
}
``````

``````parameters {
vector<lower=0>[D] sigma_1[K];
...
}
``````

and then take the [k] index off it in other places? Is that what you’re looking for?

No I mean I would like

sigma_1[K][1,1]=sigma_1[K][2,2]

does that makes sense? I am trying to impose a constraint on the variance terms.

Oh, do you mean the other thing, like:

``````real<lower=0> sigma_1[K];
``````

Then you can replace `diag_pre_multiply(sigma_1[k], L_1[k])` with `sigma_1[k] * L_1[k]`?

The diagonal of the LKJ matrices is ones, so if you multiply the cholesky of one of them by a scalar it’s like mutiplying the whole thing by that scalar squared (and so the diagonal becomes that scalar squared). That it?