I have a user defined Beta distribution.

Beta(\theta+0.5|p,q) = (0.5 + \theta)^{p-1} (0.5 - \theta)^{q-1} / B(p,q) between [-0.5,0.5]

where B(p,q) = \Gamma(p) \Gamma(q) / \Gamma(p+q)

```
real mbeta_lpdf(real theta, real p, real q) {
real lpp;
real b;
lpp = pow(0.5 + theta,p-1) * pow(0.5 - theta,q-1);
b = (tgamma(p-1)*tgamma(q-1))/tgamma(p+q-1);
return log(lpp) - log(b);
```

This Beta distribution is implemented into a hierarchical generalized extreme value (GEV) distribution for the shape parameter (`xi`

). For the location (`mu`

) and scale (`sigma`

) parameters I use a normal and gamma prior distributions respectively with uniform hyperpriors (`alpha = uniform(-infinity,+infinity)`

and `delta = uniform(0,+infinity)`

.

This is the whole model:

```
functions {
real gev_lpdf(vector y, real mu, real sigma, real xi) {
int N = rows(y);
vector[rows(y)] z;
vector[rows(y)] lp;
for(n in 1:N) {
z[n] = 1 + (y[n] - mu) * xi / sigma;
lp[n] = (1 + (1 / xi)) * log(z[n]) + pow(z[n], -1/xi);
}
return -sum(lp) - N*log(sigma);
}
real mbeta_lpdf(real theta, real p, real q) {
real lpp;
real b;
lpp = pow(0.5 + theta,p-1) * pow(0.5 - theta,q-1);
b = (tgamma(p-1)*tgamma(q-1))/tgamma(p+q-1);
return log(lpp) - log(b);
}
}
data {
int<lower=0> N; //observation and duration vector length
int<lower=1> J; //number of weather stations
vector[N] y[J]; //data matrix
}
parameters {
real<lower=-0.5,upper=0.5> xi[J];
real mu[J];
real<lower=0> sigma[J];
real alpha;
real<lower=0> delta;
}
model {
for(j in 1:J){
xi[j] ~ mbeta(6.0,9.0);
mu[j] ~ normal(alpha,25);
sigma[j] ~ gamma(delta,delta);
y[j] ~ gev(mu[j],sigma[j],xi[j]);
}
}
```

When I run this code unfortunately it throws an error:

```
...
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can't start sampling from this initial value.
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
```

Where have I gone wrong here?