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