Initialization between (-2, 2) failed after 100 attempts

Hi, friends. I have just started learning stan and rstan, facing with a problem.
First, I tried a model normal(mu, sigma) which went pretty smooth. But after changed the model to pareto(y_min, alpha) with the same sample data, I got error message with 100 of:
“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.”
I tried to restrict the range of parameters as the code attached. It looks all the parameters are restrcted above zero, and not between (-2, 2).

How can I change my code?
Your advice really appreciated.


data {
  int N; 
  vector<lower=1e6, upper=2e9>[N] y; 
}

// The parameters accepted by the model. 
parameters {
  real<lower=0> alpha;
  real<lower = 1> y_min; 
}

// The model to be estimated. 
model {
     alpha ~ uniform(1,2);
     y_min ~ uniform(1e6, 2e6);
     y ~ pareto( y_min, alpha) ;
}

sample data

library(Pareto)
set.seed(123)
N = 1e4 
alpha = 1.6
y_min = 1 
trunc = 1000 
Y = rPareto(N, y_min, alpha, truncation = trunc) 
Y = Y * 1e6

When using uniform priors you need to declare your parameters with upper and lower bounds that match those in the prior. Try:

data {
  int N; 
  vector<lower=1e6, upper=2e9>[N] y; 
}

// The parameters accepted by the model. 
parameters {
  real<lower=1, upper=2> alpha;
  real<lower=1e6, upper=2e6> y_min; 
}

// The model to be estimated. 
model {
     alpha ~ uniform(1,2);
     y_min ~ uniform(1e6, 2e6);
     y ~ pareto( y_min, alpha) ;
}
1 Like

Thank you for your very quick advice!
I tried the way as mentioned, however, still the same initialization error comes out.

Good news is that when I commented out the very last line, y ~ pareto( y_min, alpha) , iteration went well, then I assume there is something going wrong with that very last sentence.
Any other missing points I need to be aware of?
Again, your advice is really appreciated. Thanks.

I finally could run sampling with following model (not yet converging, though)
y * 1e6 ~ pareto( y_min, alpha)

Thank you for your help.