Basic question: what is lp_ in posterior samples of a brms regression?

When I extract posterior samples from a regression model generated with brms, there is a column in addition to the estimated parameters titled ‘lp_’. I have attached pictures from such a model, in this case a beta regression comparing two groups, as an example.

My simple question is: what is lp__? I have searched and see it may be something to do with log probability, but if so, what probability is it referring to? What can be done with this value, and how should I be interpreting it, if at all?

1 Like

It is the log posterior density, up to a normalizing constant.

The posterior density is defined as:

p(\theta|D) = \frac{p(D|\theta)p(\theta)}{p(D)}

The posterior density, defined up to a constant (i.e., the unnormalized posterior density):

p(\theta|D) \propto p(D|\theta)p(\theta)

The log unnormalized posterior density:

\log p(\theta|D) = \log (p(D|\theta)) + \log (p(\theta))

Stan only needs the unnormalized log posterior, up to any constants.

So when you say:

theta ~ normal(0,1)
x ~ normal(theta, 1)

This is, conceptually, translated to:

target = 0
target += log(normal_pdf(theta | 0, 1))
target += sum(log(normal_pdf(x | theta, 1)))

The “target” variable is the unnormalized, log posterior density.

In reality, using ~ statements in Stan also drops constants in the (log)density functions; like the 1/sqrt(2) in the normal density.

But Brms uses the target += syntax, so it maintains those constants.

The lp__ variable tracks the target variable. Therefore, the lp__ in brms is the unnormalized log posterior density.

In sum: lp__ in brms is equal to the unnormalized log posterior density; in general, it is equal to the ‘target’ variable, which represents the sum of the log density and mass contributions from the likelihoods and priors - Whether it is the unnormalized log posterior density depends on whether the constants are dropped (using ~ syntax) or not (using target += syntax).

10 Likes

Thank you very much for this detailed explanation!