tests/testthat/test_extract_log_lik.R

library(loo)

context("extract_log_lik")
test_that("extract_log_lik throws appropriate errors", {
  x1 <- rnorm(100)
  expect_error(extract_log_lik(x1), regexp = "Not a stanfit object")
  x2 <- structure(x1, class = "stanfit")
  expect_error(extract_log_lik(x2)) # not an S4 object OR no applicable method (depending on R version)
})

Try the loo package in your browser

Any scripts or data that you put into this service are public.

loo documentation built on March 31, 2023, 10:11 p.m.