# Warning : Chains in stan are not mixed

Hi all,
I am having trouble getting the chains to mix properly in this model. I have posted some issues earlier which are related to this model. The model can be described mathematically as:

β ~ logistic link(b_0,b_1)
w ~ log-normal(,μ,σ)
Q ~ Weibull(α,λ)
With appropriate priors on b_0,b_1,μ,σ,α,λ
Briefly, I am trying to estimate above six parameters using HMC algorithm of patinets. I assume that, β is same for all individuals in one age group. Here,I have replaced my uniform priors as mentioned in the below model. Have I misspecified my model, or do I need to use more informative priors?

``````data{
int n;
int m;
matrix[n,m] MT;
int K;
real tstar;
}

parameters{
real<lower=0.001> b0;
real<lower=-0.1> b1;
real<lower=4.5> mu;
real<lower=0.01> sigma2;
real<lower=0.01> lambda;
real<lower=1.5> alpha;
}

model{
b0 ~ normal(2,10);
b1 ~ normal(0.001,10);
mu ~ normal(4.2,10);
sigma2 ~ gamma(0.00016,0.004);
lambda ~ gamma(0.007968,0.0282269);
alpha ~ gamma(0.24025,0.155);
.
.
.
target += (MT[i,(k*3)]*log(V[k]))  + ((MT[i,((k*2)+k-1)]- MT[i,((k*3)+1)])*(log(1)-log(V[k]))) + (MT[i,((k*3)+1)]*log(I[k]))+ ((MT[i,((k*2)+k-1)]-MT[i,(k*3)]-MT[i,((k*3)+1)])*(log(1)-log(V[k])-log(I[k])));
}
``````
``````inits = list(list(b0=runif(1,0,4)),
list(b1=runif(1,-0.1,0.1)),
list(mu=runif(1,4,4.5)),
list(sigma2=runif(1,0.01,0.05)),
list(lambda=runif(1,0.01,0.5)),
list(alpha=runif(1,1.5,4)))

fit<-stan(model_code = cancer_code,
data = cancer_data,
iter = 10000,
warmup = 5000,
init = inits,
init_r = 0.1,
chains = 4,
refresh = 0,
control=list(max_treedepth=10))
``````

This gives me several warnings as model chains are not well mixed, I am confused here, I want to know that is it an error of initial parameter values or error of defining prior distributions?

Thank you.

Edit: @maxbiostat edited this post for syntax highlighting and code formatting

Start by simulating parameters from your priors and fake data from your data model given these parameters, then run Stan and see if it mixes ok and recovers the parameters.

Also don’t run for 10000 iterations; that’ll just delay you while you’re waiting for it to not converge.

Remove the bounds on the parameters (except for zero lower bounds on parameters that are constrained to be positive).

These won’t necessarily fix your problems, it’s just some starting steps. If you can’t recover your parameters from fake data, try simplifying the model until you get this to work.

I changed lower bounds of parameters as you suggested and I started to fit a model 100 iterations instead of what I have used earlier, In my case i want to have positive parameter values for all except b_1. Please anyone help me to have some idea of using init-r argument (not in a control argument list) with initial values which places in stan function.

Further, please advice me how to use generated quantities block for above my code?

The structure of data table what I am using with the above code is as follows:
data.csv (223 Bytes)