Hi there,
A quite short question
I used a very simple model, Y=\tau_n+\tau_s+\tau_c+N(0,5), and I wish the three parameters following the dependent prior: \tau_n<\tau_s<\tau_c, so all posterior samples of the three parameters should obey the rule.
In fitting, I used three different Stan program scripts
Choice 1
functions{
real mylpdf_lpdf(vector X, vector D, vector sigma_square, real tau_n, real tau_s, real tau_c){
real lprob;
if(tau_n<tau_s && tau_s<tau_c){lprob=normal_lpdf(X| D , sqrt(sigma_square) ); }
else{
lprob=negative_infinity();
}
return lprob;
}
}
data{
int<lower=1> N;
vector[N] Y; //responses
}
parameters{
real<lower=0,upper=20> tau_n;
real<lower=0,upper=20> tau_s;
real<lower=0,upper=20> tau_c;
}
model{
vector[N] mu;
vector[N] sigma_square;
for ( i in 1:N ) {
sigma_square[i] =5;
}
for ( i in 1:N ) {
mu[i] = tau_n+tau_s+tau_c;
}
Y ~ mylpdf( mu , sigma_square,tau_n,tau_s,tau_c );
Choice 2
functions{
real dependent_flat_lpdf(vector y){
if(y[1]<y[2] && y[2]<y[3])
return 1;
else
return negative_infinity();
}
}
data{
int<lower=1> N;
vector[N] Y; //responses
}
parameters{
real<lower=0,upper=20> tau_n;
real<lower=0,upper=20> tau_s;
real<lower=0,upper=20> tau_c;
}
transformed parameters{
vector[3] taus;
taus[1]=tau_n;
taus[2]=tau_s;
taus[3]=tau_c;
}
model{
vector[N] mu;
vector[N] sigma_square;
taus ~ dependent_flat();
for ( i in 1:N ) {
sigma_square[i] =5;
}
for ( i in 1:N ) {
mu[i] = tau_n+tau_s+tau_c;
}
Y ~ normal( mu , sqrt(sigma_square) );
}
Choice 3
data{
int<lower=1> N;
vector[N] Y; //responses
}
parameters{
real<lower=0,upper=20> tau_n;
real<lower=0,upper=20> tau_s;
real<lower=0,upper=20> tau_c;
}
model{
vector[N] mu;
vector[N] sigma_square;
for ( i in 1:N ) {
sigma_square[i] =5;
}
for ( i in 1:N ) {
mu[i] = tau_n+tau_s+tau_c;
}
if(tau_n<tau_s && tau_s<tau_c){
Y ~ normal( mu , sqrt(sigma_square));}
else{ target+=negative_infinity(); }
}
To my knowledge, the three Stan scripts are the same and will generate the similar results, and indeed they are. The ESS and \hat{R} and even traceplots are also good. The 95% credibility intervals contain the real true values as well. However, I was told
There were ``` divergent transitions after warmup. Increasing adapt_delta above 0.85 may help.
and the pairs() shows
Can I trust the MCMC results? If not, how can I improve the model without the change to the assumption \tau_n<\tau_s<\tau_c?
Thanks in advance for any tips and kind help.