log_likelihood: Compute the (log-)likelihood of a probability distribution...

View source: R/methods.R

log_likelihoodR Documentation

Compute the (log-)likelihood of a probability distribution given data

Description

Functions for computing the (log-)likelihood based on a distribution object and observed data. The log-likelihood is computed as the sum of log-density contributions and the likelihood by taking the exponential thereof.

Usage

log_likelihood(d, x, ...)

likelihood(d, x, ...)

Arguments

d

An object. The package provides methods for distribution objects such as those from Normal() or Binomial() etc.

x

A vector of data to compute the likelihood.

...

Arguments passed to methods. Unevaluated arguments will generate a warning to catch mispellings or other possible errors.

Value

Numeric value of the (log-)likelihood.

Examples

## distribution object
X <- Normal()
## sum of log_pdf() contributions
log_likelihood(X, c(-1, 0, 0, 0, 3))
## exp of log_likelihood()
likelihood(X, c(-1, 0, 0, 0, 3))

distributions3 documentation built on Sept. 30, 2024, 9:37 a.m.