tests/testthat/test_savage_dickey.R

library(LRO.utilities)
library(ggplot2)
context("savage_dickey")

test_that("savage_dickey() works correctly", {

  set.seed(1)
  prior <- rnorm(100, mean=0, sd=1)
  set.seed(1)
  posterior <- rnorm(100, mean=2, sd=2)

  expect_equal(savage_dickey(posterior, prior, Q = 0, print_plot = FALSE, plot = FALSE),
               list("BF10" = 0.151, "BF01" = 6.582,
                    "Maximum a posteriori at Q" = 0.08096914,
                    "Maximum a priori at Q" = 0.5329606
                    ), tolerance=1e-2)

  # Doesn't test the ggplot object!

})
LudvigOlsen/LRO.utilities documentation built on Nov. 13, 2020, 11:26 a.m.