I am having trouble with a model that predicts when events such as budburst or flowering occur in plants. I use the same model for all events but run the model on each set of event data separately. The slope and intercept are partially pooled for different winegrape varieties. The model runs fine with my test data but not on the real data for one of the events.
My problem is the sigma of my slope (s_bvar in my code) which had many divergent transitions and a banana in the log posterior vs the parameter plot in my original model. I tried a non-centered parameterization of the model (stan code shown). However, with the NCP, the model still has divergent transitions and the log posterior vs parameter plot now shows the slope sigma clustering towards 0.
What problem with data or my model might cause these sigma problems?
data{
int<lower=0> N; //all the samples
vector[N] x; // year predictor
vector[N] y; // predicted GDD of event date
int<lower=1> Nv; // number of varieties
int<lower=1, upper=Nv> variety[N]; // variety ID numbers
}
parameters{
vector[Nv] a_var;
vector[Nv] b_raw; // slope ncp part 1
real mu_a; // mu, one per variety
real mu_b; // mu, one per var
real<lower=0> s_avar; // for alpha, one per var
real<lower=0> s_bvar; // for beta, one per var
real<lower=0> sigma_y; // error
}
transformed parameters {
vector[Nv] b_var;
b_var = mu_b + s_bvar * b_raw; // ncp part 2
}
model{
// likelihood
for (n in 1:N)
y[n] ~ normal(a_var[variety[n]] + b_var[variety[n]]*x[n], sigma_y);
//priors
a_var ~ normal(mu_a, s_avar);
b_raw ~ normal(0,1);
mu_a ~ normal(1000,500);
mu_b ~ normal(0,5);
s_avar ~ normal(100,50);
s_bvar ~ normal(0,20);
sigma_y ~ normal(0,20);
}