swh:1:snp:2c68a6c5a8af2f06ac2c0225927f25b54fd1f9d0
Raw File
Tip revision: 23ea3229abe72a5f23dcf3a4cfcd3478d744b536 authored by Dominique Makowski on 20 June 2019, 11:50:03 UTC
version 0.2.2
Tip revision: 23ea322
test-hdi.R
context("hdi")

test_that("hdi", {
  testthat::expect_equal(hdi(rnorm_perfect(1000), ci = .90)$CI_low[1], -1.64, tolerance = 0.02)
  testthat::expect_equal(nrow(hdi(rnorm_perfect(1000), ci = c(.80, .90, .95))), 3, tolerance = 0.01)
  testthat::expect_equal(hdi(rnorm_perfect(1000), ci = 1)$CI_low[1], -3.09, tolerance = 0.02)
  testthat::expect_equal(length(capture.output(print(hdi(rnorm_perfect(1000))))), 5)
  testthat::expect_equal(length(capture.output(print(hdi(rnorm_perfect(1000), ci = c(.80, .90))))), 10)


  testthat::expect_warning(hdi(c(2, 3, NA)))
  testthat::expect_warning(hdi(c(2, 3)))
  testthat::expect_warning(hdi(rnorm_perfect(1000), ci = 0.0000001))
  testthat::expect_warning(hdi(rnorm_perfect(1000), ci = 950))
  testthat::expect_warning(hdi(c(rnorm_perfect(1000, 0, 1), rnorm_perfect(1000, 6, 1), rnorm_perfect(1000, 12, 1)), ci = .10))
})
back to top