Dear all,
I’m currently working on a project where I’d like to use Stan to transform the values I’ve drawn from a particular normal distribution to the equivalent value from the truncated normal distribution. I’d like to do this in stan because I reference the value immediately below. In addition, when I use R for truncation, there’s a weird spike at the halfway point of the lower bound (5) in this case. However, I’m not sure how to do so. I’ve tried by specifying the below (alpha_jdy[n] is the vector of values I’d like to convert) but I keep running into issues where I get the below error. I’ve tried specifying the init_r
as various negative value.
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.
[1] "Error in sampler$call_sampler(args_list[[i]]) : Initialization failed."
This is my code.
// The input data is the module-year mu for
data {
int<lower=0> N;
vector[N] alpha_jdy;
vector[N] mu_my;
vector[N] sigma_mu;
vector[N] sigma_alpha;
}
//
parameters {
vector[N] alpha_hat_jdy;
}
//
model {
for (n in 1:N) {
alpha_jdy[n] ~ normal(mu_my[n], sigma_mu[n]) T[-10, 0];
alpha_hat_jdy[n] ~ normal(alpha_jdy[n], sigma_alpha[n]);
}
}
Thanks!
C