I’m trying to port a hierarchical repeat sales index model from BUGS , the original code from the paper is attached (I think the author is @avdminne, ) . My Stan model compiles and fits, but I need to turn max_treedepth up to at least 14 in order to avoid warnings - usually all or almost all iterations exceed the treedepth at default settings. This is fine but taking max_treedepth from 10 to 14 lengthens the runtime 6x+ and I’m already only using a subset of the data. Is there anything I could try to avoid a higher treedepth, maybe reparameterization tricks or alternative priors?

I also read on the “Guide to Errors” about looking for parameters correlated with energy_ , but I have a lot of parameters and since all iterations typically exceed the max_treedepth I wonder whether I’m defining something in a not ideal way.

```
data {
int<lower=1> N; // N observations
int<lower=1> Na; // N areas
int<lower=1> Nt; //N timeperiods
vector[N] y; // log price diff
int<lower=1> month1[N]; //month of repeat trxn
int<lower=1> month0[N]; //month of first trxn
int<lower=1> area_id[N]; // area id
real<lower=0> adf; // parameter for DoF
}
parameters {
real<lower=0> sigma_y;
real beta[Nt];
real inc[Nt];
real kappa[Nt];
real<lower=0> tau_alpha;
real<lower=0> tau_kappa;
real<lower=0> tau_eta;
matrix[Na,Nt] alpha;
real<lower=1> nu; // degrees of freedom for t
}
transformed parameters {
real mu_beta[Nt];
real mu[N];
mu_beta[1] = 0;
for (t in 2:Nt){
mu_beta[t] = beta[t-1]+inc[t]*kappa[t]; // 'matt trick?'
}
for (i in 1:N){
mu[i] = (beta[month1[i]] - beta[month0[i]]) +
(alpha[area_id[i], month1[i]] - alpha[area_id[i], month0[i]]);
}
}
model {
// Priors
sigma_y ~ inv_gamma(0.1,0.1);
tau_alpha ~ lognormal(5,1);
tau_kappa ~ inv_gamma(0.001, 0.001);
tau_eta ~ inv_gamma(0.001, 0.001);
nu ~ exponential(adf);
beta ~ normal(mu_beta, tau_eta);
inc ~ normal(0,1);
for (t in 2:Nt) {
kappa[t] ~ normal(kappa[t-1], tau_kappa);
}
for (a in 1:Na){
for (t in 2:Nt){
alpha[a,t] ~ normal(alpha[a,t-1], tau_alpha);
}
}
y ~ student_t(nu, mu, sigma_y);
}
```

I’m omitting the other hierarchical features for property types that is in the BUGS model. Also I tried to incorporate the “Matt trick” as described in this other post Structural Time Series research using Stan.

EDIT: Based on reading discussions elsewhere and the guide to priors it seems like inverse gamma priors are necessary for BUGS but not ideal for Stan, I’ve changed them to standard student_t with DoF between 2-4.