Example in computing 1D integral: My misunderstanding, or a typo?

In the documentation for Computing One Dimensional Integrals, an example is given for calling the integrator for a left-truncated normal distribution. The documentation makes clear that this is just an example, and that there are better ways to model left-truncated outcomes in Stan, but gives the code:

parameters {
  real mu;
  real<lower=0.0> sigma;
  real left_limit;
}

model {
  mu ~ normal(0, 1);
  sigma ~ normal(0, 1);
  left_limit ~ normal(0, 1);
  target += normal_lpdf(y | mu, sigma);
  target += log(integrate_1d(normal_density,
                             left_limit,
                             positive_infinity(),
                             { mu, sigma }, x_r, x_i));
}

I understand this code as using the likelihood function:

p(y_i | \mu, \sigma, y_i > \text{left_limit}) = \mathcal{N}(y_i | \mu, \sigma) \cdot P(y_i > \text{left_limit} | \mu, \sigma)

But shouldn’t the likelihood function for a left-truncated normal be:

p(y_i | \mu, \sigma, y_i > \text{left_limit}) = \frac{\mathcal{N}(y_i | \mu, \sigma)}{P(y_i > \text{left_limit} | \mu, \sigma)}

Then that would mean the log of the integral in the above code should be subtracted, not added? Please forgive me if I misunderstood something obvious.

Yes, this should be subtracted. Thanks for the correction. We’ll update the doc. I created the following issue: