I am recreating some model results from a paper, and am unsure whether I’m setting up the model properly in my stan code.

The outcome is defined as:

Y ~ N(\theta_pbs, \sigma^2)

and the prior distributions for the parameters are:

[\theta_pbs] ~ N(\theta_0, \tau^2)

[sigma^2] ~ IG(\alpha, \beta)

and the paper states that the following prior values are used:

\theta_0 = 0

\tau = 1

\alpha = 0.001

\beta = 0.001

My stan code was set up as shown below.

```
data {
int<lower=0> N_pbs;
vector[N_pbs] y_pbs;
}
parameters {
real theta_0;
real tau;
real sigma;
real theta_pbs;
real<lower=0.000001> alpha;
real<lower=0.000001> beta;
}
// Setting lower bounds here to restrict alpha, beta to positive real numbers
model {
y_pbs ~ normal(theta_pbs, pow(sigma, 2));
theta_pbs ~ normal(theta_0, pow(tau,2));
sigma ~ inv_gamma(alpha, beta);
}
```

The data, Y_pbs, is just simulated from a normal distribution in R with a mean 0 and a sd of 0.8.

```
set.seed(10473)
y_pbs = rnorm(n = 400, mean = 0, sd = 0.8)
```

I then run the sampling in R using rstan, with the following setup:

```
data = {
y_pbs = y_pbs,
N_pbs = length(y_pbs),
theta_0 = 0,
tau = 1,
alpha = 0.001,
beta = 0.001
}
mod_test <- stan_model(file = "first_stan.stan")
res <- rstan::sampling(mod_test,
data = data,
chains = 4,
iter = 2000,
seed = seed,
cores = 4)
```

I ended up with the following warnings

```
Warning messages:
1: There were 67 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
2: There were 3760 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
https://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
3: Examine the pairs() plot to diagnose sampling problems
4: The largest R-hat is 2.76, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
5: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
6: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
```

I just want to make sure that I’m setting up the priors and model correctly, to determine whether the issues related to the model specification itself.

Thanks for any help in advance.