For the left-censored data the CDF (normal_lcdf) has to be used instead of complementary CDF. If the censoring point variable (L) is unknown, its declaration should be moved from the data to the parameters block.
data {
int<lower=0> N_obs;
int<lower=0> N_cens;
array[N_obs] real y_obs;
}
parameters {
real<upper=min(y_obs)> L;
real mu;
real<lower=0> sigma;
}
model {
L ~ normal(mu, sigma);
y_obs ~ normal(mu, sigma);
target += N_cens * normal_lcdf(L | mu, sigma);
}
But why does L also follow the normal prior with the mean mu and SD sigma? In my opinion, it should be something like min(y_obs) - L ~ exponential(0.1)
A prior that depends on min(y_obs) is a data dependent prior. The idea in the users’ guide is that we don’t know a priori where L is. If we have further prior information about where L should be, beyond “somewhere in the range of plausible data”, then we would put that in our prior.
Now, the data/likelihood immediately rule out all values of L greater than min(y_obs), which is why we declare L with an upper bound constraint. In this case, this constraint can be thought of as a computational lubricant for a model that must enforce what the likelihood says, which is that L greather than min(y_obs) is impossible.
Thanks for your response! I understand the implication of declaring the prior for L, I think it is a very good approach. I questioned more, why the prior for L should follow the normal prior with mu and sigma by itself rather than some other considerations.
For example, I may fix L around 95th or 99th percentile and add some variation about that, i.e. L ~ normal(mu - 3 * sigma, sigma_L);
Sometimes people simply fix L = mu - 3 * sigma, but my understanding is that it is better to add some flexibility.
If you know a priori that L is near the first percentile, then by all means this is a reasonable approach. In many cases, I’m not sure how you would know this–L probably depends more on the measurement instrument than the mean and sd of the population. Alternatively, if you have some a priori information about the value of L directly, you could put a prior directly around the suspected value, not dependent on mu or sigma.
Usually normal priors are sufficient if all you care about is adding some weakly informative scale information. But your situation is more complex and I should have caught this the first time. You should be sampling L as
L ~ normal(mu, sigma) T[ , min(y_obs)];
because mu and sigma are parameters. If they were constants, you could drop the truncation. You can give it other distributions other than normal, but if it depends on parameters, it is going to need the truncation statement (it just subtracts normal_lcdf(min(y_obs) | mu, sigma) from the target to account for the truncation, and we need this, because it depends on mu and sigma.
If you have better prior information than just knowing the rough scale, then by all means use it!
I’m not sure how censoring with an unknown boundary arises. Censoring usually means that values outside of a range are marked as being beyond one range or the other. To do that, you need to know the range. For example, I might censor all observations above 300 pounds on a domestic scale because that’s as high as it reads. Or I might censor all observations below 1g on a kitchen scale because that’s all the resolution it has.