log_lik.brmsfit

0th

Percentile

Compute the Pointwise Log-Likelihood

Compute the Pointwise Log-Likelihood

Usage
# S3 method for brmsfit
log_lik(object, newdata = NULL, re_formula = NULL,
  resp = NULL, nsamples = NULL, subset = NULL, pointwise = FALSE,
  combine = TRUE, ...)
Arguments
object

A fitted model object of class brmsfit.

newdata

An optional data.frame for which to evaluate predictions. If NULL (default), the original data of the model is used.

re_formula

formula containing group-level effects to be considered in the prediction. If NULL (default), include all group-level effects; if NA, include no group-level effects.

resp

Optional names of response variables. If specified, predictions are performed only for the specified response variables.

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.

subset

A numeric vector specifying the posterior samples to be used. If NULL (the default), all samples are used.

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 log_lik directly, but rather when computing waic or loo.

combine

Only relevant in multivariate models. Indicates if the log-likelihoods of the submodels should be combined per observation (i.e. added together; the default) or if the log-likelihoods should be returned separately.

...

Further arguments passed to extract_draws that control several aspects of data validation and prediction.

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. For multivariate models and if combine is FALSE, an S x N x R array is returned, where R is the number of response variables. If pointwise = TRUE, the output is a function with a draws attribute containing all relevant data and posterior samples.

Aliases
  • log_lik.brmsfit
  • log_lik
  • logLik.brmsfit
Documentation reproduced from package brms, version 2.9.0, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.