Truncation in target +

Hi,

The code below has 2 ways of writing out a model: one with the target+= syntax and the simplified syntax.

Is the “- normal_lccdf( 0 | 0, 10);” always needed when using the target+= syntax? And it is never needed when using the simplified syntax?


data{
vector[N] y;
}

parameters{
  real a;
  real<lower=0> sigma;
} 
//traget+=
model{
  target += normal_lpdf(a | 0,4);
  target += normal_lpdf(sigma | 0,10) - normal_lccdf( 0 | 0, 10);
  target += normal_lpdf(y | a , sigma);
} 
//simplified 
model{
  a ~ normal(0,4);
  sigma ~ normal(0,10);
  y ~ normal(a, sigma);
} 

Thank you!

Correct parameter estimation requires only the posterior density up to an unknown multiplicative normalizing constant, which means that constant multiplicative terms (additive terms on the log scale) can be dropped. [Aside: it’s not an accident that Stan works with the gradient of the log density and dropping these additive terms doesn’t affect the gradient]. Thus, the normal_lccdf term can in general be dropped regardless of whether you’re using ~ or target +=. However, there are specific applications where it matters to retain the normalizing constants. The main ones that I can think of are when you intend to work with Bayes factors or when you are computing terms that are to be used as mixture components. Importantly, the ~ notation already drops other relevant normalizing constants for computational efficiency. y ~ Distribution(theta) means target += distribution_lupdf(y | theta). I cannot think of any reason why it would ever be relevant or useful to add the normal_lccdf term back in when you are already dropping normalizing constants via the ~ syntax.

2 Likes