Please share your Stan program and accompanying data if possible.
When including Stan code in your post it really helps if you make it as readable as possible by using Stan code chunks (```stan) with clear spacing and indentation. For example, use
data {
int <lower=1> N; //number of data points
vector [N] Reaction; //response variable
//int < lower=1, upper=10> Days[N]; // covariate
int<lower=1> J;// number of subjects
int<lower=1> K; // no of Days
int<lower=1, upper=J> subj[N]; // number of subjects
int<lower=1, upper=K> Days[N]; // number repeated measures (times)
}
parameters{
vector[2] beta; // number of fixed effects (intercept and slope)
real <lower=0> sigma_e; //error sd
vector<lower=0> [2] sigma_u; //subject sd
cholesky_factor_corr[2] L_u;
matrix[2,J] z_u;
}
transformed parameters{
matrix[2,J] u;
u<-diag_pre_multiply(sigma_u, L_u)* z_u;//subject random effects
}
model {
real mu;
//priors
beta [2]~normal(0,100);
sigma_e~cauchy(0,15);
L_u~ lkj_corr_cholesky(2.0); //subject random effects
to_vector(z_u)~normal(0,1);
// likelihood
for (i in 1:N){
mu= beta[1]+u[1,subj[i]]+ beta[2]*Days[i]+u[2,subj[i]] * Days[i];
Reaction[i] ~normal(mu,sigma_e);
}
}
}
****
To include mathematical notation in your post put LaTeX syntax between two `$` symbols, e.g.,
$log(\mu)=X\beta+ZU$.
where U is refers random intercept and random slope. With the LKJ prior could anybody help me to construct the mathematical form of the posterior. The parameter involves here beta, sigma_e, U and the variance covariance matrix of U,