Learn R Programming

brms (version 1.1.0)

logLik.brmsfit: Compute the pointwise log-likelihood

Description

Compute the pointwise log-likelihood

Usage

"logLik"(object, newdata = NULL, re_formula = NULL, allow_new_levels = FALSE, subset = NULL, nsamples = NULL, pointwise = FALSE, ...)

Arguments

object
A fitted model object of class brmsfit.
newdata
An optional data.frame for which to evaluate predictions. If NULL (default), the orginal data of the model is used.
re_formula
formula containing random effects to be considered in the prediction. If NULL (default), include all random effects; if NA, include no random effects.
allow_new_levels
A flag indicating if new levels of random effects are allowed (defaults to FALSE). Only relevant if newdata is provided.
subset
A numeric vector specifying the posterior samples to be used. If NULL (the default), all samples are used.
nsamples
Positive integer indicating how many posterior samples should be used. If NULL (the default) all samples are used. Ignored if subset is not NULL.
pointwise
A flag indicating whether to compute the full log-likelihood matrix at once (the default), or just return the likelihood function along with all data and samples required to compute the log-likelihood separately for each observation. The latter option is rarely useful when calling logLik directly, but rather when computing WAIC or LOO.
...
Currently ignored

Value

Usually, an S x N matrix containing the pointwise log-likelihood samples, where S is the number of samples and N is the number of observations in the data. If pointwise = TRUE, the output is a function with a draws attribute containing all relevant data and posterior samples.