# Help with non-linear model [Log probability evaluates to log(0)]

Hello, I have the following (test) data.

``````stan_data <- list(
N = 25,
Y = c(0.8333333,0.6000000,0.6000000,1.5000000,1.4166667,0.0500000,0.5500000,2.0000000,
1.5000000,2.1666667,2.9500000,0.7187500,1.3000000,0.4000000,0.8750000,1.3000000,
1.6000000,0.4438603,0.2083333,1.0937500,0.4642857,0.1500000,2.9000000,1.1666667,
1.2083333),
x = c(12.9000,5.6000,1.0000,0.9000,33.7500,11.5000,18.1500,15.3500,13.6500,18.0000,16.2500,
16.1000,21.7000,5.7000,10.2000,16.4000,17.1000,35.9483,6.9000,5.5000,8.3000,0.5500,
17.2000,6.8500,9.7500)
)
``````

Existing models for similar data have the non-linear form y = exp(b0 + b1 * sqrt(x) + b2 * x)
There are priors coming from those models for b0, b1 and b2, so here is my tentative stan model:

``````data {
int<lower=0> N;
real x[N];
real<lower=0> Y[N];
}
parameters {
real b0;
real b1;
real b2;
real<lower=0> beta;
}
transformed parameters {
real m[N];
for (i in 1:N)
m[i] = exp(b0 +b1*sqrt(x[i]) +b2*x[i]);
}
model {
// priors
b0 ~ normal(-10, 1);
b1 ~ normal(0.2, .5);
b2 ~ normal(-.05, .02);
// likelihood
Y ~ gamma(m, beta);
// no priors for the beta parameter: is that fine?
}
``````

When I try to run the model

``````stan(my_stan_model, data = stan_data, iter = 1000, chains = 4, verbose = TRUE)
``````

I got 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.

Reading around, it seems there is something wrong in my model formulation. Any suggestions? Thanks!

When using uniform priors you need to include matching `lower` and `upper` bounds in the parameter declaration

Actually it was a mistake. I had realized I wrongly assigned Uniform instead of Normal to b2 and then saw your answer :)