Hi, so I am trying to fit the marginal R2-D2 prior in the multiple linear regression setting without random effects in Rstan. The prior is specified on page 10 equation 10 of this article: https://arxiv.org/pdf/1609.00046.pdf

The prior is:

{\beta}_j \mid \sigma^2, {\lambda}_j \sim DE{(\sigma({\lambda}_j/2)}^{(1/2)}), {\lambda}_j \mid \xi \sim Ga( a_{\pi},\xi), \xi \sim Ga(b,1)

In addition, there is an inverse-gamma prior on \sigma^2: \sigma^2 \sim invgamma(0.001,0.001). Moreover, we set b = 0.5, and a_{\pi} = 1/(p^{b/2}n^{b/2}logn) where p is the number of predictors, around 500, and n = 60 Is the number of data points.

This is my attempt so far at implementing the prior with Stan:

```
data {
int<lower=1> n; // Number of data
int<lower=1> p; // Number of covariates
matrix[n,p] X; // n-by-p design matrix
real y[n]; // n-dimensional response vector
int n_nonzero; // number of nonzero beta
}
parameters {
vector[p] beta;
vector<lower=0>[p] lambda;
real<lower=0> ksi;
real<lower=0> sigma;
}
transformed parameters {
vector[n] theta ;
theta = X * beta;
}
model {
ksi ~ gamma(0.5,1);
lambda ~ gamma( 1/(p^(0.025)*n^(0.025)*log(n)), ksi);
sigma ~ inv_gamma(0.001,0.001);
for (j in 2:p) {
beta[j] ~ double_exponential(0, sqrt(sigma)*(lambda[j]*0.5)^(0.5));
}
y ~ normal(theta, sigma);
}
```

There are two major issues Iâ€™m having with this code.

Number one: the mixing is very bad. I receive many warnings that the chain is not mixing properly. Large R-hat, Bulk Effective and Tail Effective Samples Size too low etc.

Number two: The code takes about 5 minutes to run with one chain, which is a lot longer than I was hoping for. Would be very nice if it was possible to make it run faster.

Appreciate any help.