Hello Stan users,
I have created 640 observations (data is attached in CSV format) in the following form:
Y = alpha - u + error.
where alpha is intercept with value of 0.10
u comes from a truncated normal distribution [0, ] with mean (mu_u) of 0.20 and standard deviation (sigma_u) of 0.15
and error comes from a normal distribution of mean zero and standard deviation (sigma) of 0.13.
I am trying to recover the values of alpha, mu_u, sigma_u and sigma.
However I am having issues in recovering the model parameters with divergences and recovered parameters way off from what I created.
Here is the output of my recovery model.
Here is the Stan code I am using
data {
int<lower=0> N; // Number of obs
vector[N] Y;
}
parameters {
real mu_u;
real alpha;
real<lower=0> sigma;
real<lower=0> sigma_u;
vector<lower=0>[N] u;
}
transformed parameters{
vector[N] yhat;
yhat = alpha - u;
}
model {
alpha ~ normal(0,1);
sigma ~ cauchy(0, 1);
target += normal_lpdf(u | mu_u, sigma_u);
for (n in 1:N)
if (u[n] < 0)
target += negative_infinity();
else
target += normal_lpdf(mu_u |0,1);
target += cauchy_lpdf(sigma_u | 0,1);
target += -normal_lccdf(0 | mu_u, sigma_u);
Y ~ normal(yhat, sigma);
}
generated quantities {
}
Can someone please help with this recovery process. I have spend couple of days working on this with no success.
Thanks
simulated_data_set.csv (10.2 KB)