Skip to contents

Calculates the log probability mass function (log-PMF) and log cumulative distribution function (log-CDF) for a logistic model based on a fitted 'brms' model.

Usage

log_pred_dist_bern(fit)

Arguments

fit

A fitted model object from brms.

Value

A list containing:

  • lpmf_hat: numeric matrix of log-PMF values (posterior draws × observations).

  • lcdf_hat: numeric matrix of log-CDF values (posterior draws × observations).

Details

The function extracts the posterior predictions of the Bernoulli component (structural zeros) using posterior.pred() for the mean parameter ("mu").

For each observation:

  • Computes the log-PMF of the observed binary outcome.

  • Computes the log-CDF (upper-tail probability) of the observed outcome.

This produces matrices of size \(M \times N\), where \(M\) is the number of posterior draws and \(N\) is the number of observations.

Examples

# Assuming 'fit' is a fitted brms logistic model
# pred_dist <- log_pred_dist_bern(fit)
# lpmf_hat <- pred_dist$lpmf_hat
# lcdf_hat <- pred_dist$lcdf_hat