calc_ll: Calculate the log-likelihood of the posterior predictive...

View source: R/calc_ll.R

calc_llR Documentation

Calculate the log-likelihood of the posterior predictive distribution

Description

Calculate the log-likelihood of the posterior predictive distribution

Usage

calc_ll(x, response, upper = NA, censored = NULL, cens = TRUE)

Arguments

x

A dataframe of posterior predictions.

response

The name of the response variable.

upper

For interval censoring, the upper bound (y2 argument to brms::cens()). Extracted from the model object by loo_cv(), but defaults to the response variable if not supplied.

censored

The name of the censoring indicator.

cens

Logical. Is the response censored?

Value

A matrix of log-likelihoods.

Examples

library("brms")
seed <- 1
data <- read.csv(paste0(system.file("extdata", package = "bgamcar1"), "/data.csv"))
fit <- fit_stan_model(
   paste0(system.file("extdata", package = "bgamcar1"), "/test"),
   seed,
   bf(y | cens(ycens, y2 = y2) ~ 1),
   data,
   prior(normal(0, 1), class = Intercept),
   car1 = FALSE,
   save_warmup = FALSE,
   chains = 3
 )
 ll_in <- add_pred_draws_car1(data, fit, draw_ids = 1:10, car1 = FALSE)
 calc_ll(ll_in, "y", "y2", "ycens")

bentrueman/bgamcar1 documentation built on July 6, 2024, 11:16 p.m.