Thank you for your suggestion betanalpha. I tried increasing my adapt delta to 0.9999 and higher and also tried different step sizes but that is not solving the divergence issues. Also for my problem its difficult to reparametrize since its a multivariate problem.

‘’’

data {

int<lower=1> N;

int<lower=1> K;

matrix[N, K] x;

vector[K] zero_vec;

matrix[K, K] I_mat;

vector[N] Y_fit;

}

parameters {

//beta

vector alpha;

vector<lower=0, upper=1> [K] beta;

real mu_alpha;

vector<lower=0> [K] mu_beta;

real<lower=0> sigma_alpha;

cov_matrix [K] Var_Cov;

cov_matrix [K] Var_Cov_mu;

}

model {

mu_alpha ~ student_t(1, 2, 2);

sigma_alpha ~ cauchy(0, 2.5);

// Prior

beta ~ multi_normal(zero_vec, Var_Cov);

mu_beta ~ multi_normal(zero_vec, Var_Cov_mu/0.01);

Var_Cov ~ inv_wishart(K, I);

Var_Cov_mu ~ inv_wishart(K, I);

alpha ~ normal(mu_alpha, sigma_alpha);

sigma ~ normal(0,100);

for(i in 1:N){

Y_fit[i] ~ normal(alpha[i] + beta_std[i, 1] * x[i, 1] + beta_std[i, 2] * x[i, 2]

+ beta_std[i, 3] * x[i, 3], sigma);

}

}

‘’’