I am receiving the following error message when running my code. Not sure what is the error message referring to. Any help would be appreciated.

```
MIX_Model = "model{
for (i in 1:n) {
y[i] ~ dnorm(mu[z[i]], tau)
z[i] ~ dcat(group_probs)
}
group_probs ~ ddirich(d)tau ~ dgamma(0.15, 0.1)
for (j in 1:ngroups) {
mu_raw[j] ~ dnorm(0, 1E-6)
d[j] = 2sd[j] = pow(tau,-0.5)
}
mu = sort(mu_raw)
}"
tc2 = textConnection(MIX_Model)
mm = jags.model(tc2, data = galax_Data, n.chains = 4)
update(mm, n.iter = 100000)
samples_g = coda.samples(mm,variable.names = c("group_probs","tau","sd"),n.iter = 100000)
mydic = dic.samples(mm,n.iter = 100000)
galax_samples_mx2 = as.matrix(samples_g[[1]])
rmix = function(y, group_probs, group_means, group_sds) {
group1_density = dnorm(y, group_means[1], group_sds[1])
group2_density = dnorm(y, group_means[2], group_sds[2])
mix_density = group_probs[1] * group1_density + group_probs[2] * group2_density
return(mix_density)}
dens = rmix(scale(galaxies)[1:82,],
c(mean(galax_samples_mx2[, 1]), mean(galax_samples_mx2[, 2])),
c(mean(galax_samples_mx2[, 3]), mean(galax_samples_mx2[, 4])),
c(mean(galax_samples_mx2[, 5]), mean(galax_samples_mx2[, 6])))
plot(scale(galaxies)[1:82, ],
dens,
col = "red",
xlab = "galaxies",
type = "l")
```

```
Error in galax_samples_mx2[, 6] : subscript out of bounds
``
```