Skip to contents

Calculate log likelihood parametrised by "mu"

Usage

log_likelihood(family, mu, Y, ...)

Arguments

family

a description of the error distribution and link function to be used in the model. This can be a character string naming a family function, a family function or the result of a call to a family function. (See family for details of family functions.)

mu

a numeric vector with values of the "main" parameter of the distribution specified by the family argument

Y

a numeric vector of the response variable in which to evaluate the density

...

arguments passed on to the S3 generic log_density

Value

numeric Value of log-likelihood

Details

See log_density for more details

Examples

# Create a test data
n <- 100
x1 <- rnorm (n)
x2 <- rbinom (n, 1, .5)
b0 <- 1
b1 <- 1.5
b2 <- 2
lin_pred <- b0+b1*x1+b2*x2
known_sigma <- 1

y_norm <- rnorm(n, mean = lin_pred, sd = known_sigma)
model_matrix_norm <- as.matrix(
   data.frame(int = 1, X1 = x1, X2 = x2))

b_prior <- 1:3

mu <- model_matrix_norm %*% b_prior

log_likelihood(family = gaussian,
               mu = mu,
               Y = y_norm,
               sd = known_sigma)
#> [1] -179.9025