https://github.com/cran/bayestestR
Tip revision: 40f7c88ddf855896018cf20ec8a7ac5fbd0ea2fb authored by Dominique Makowski on 27 January 2020, 05:30:28 UTC
version 0.5.1
version 0.5.1
Tip revision: 40f7c88
test-estimate_density.R
if (requireNamespace("logspline", quietly = TRUE) &&
requireNamespace("KernSmooth", quietly = TRUE) &&
requireNamespace("mclust", quietly = TRUE)) {
context("estimate_density")
test_that("estimate_density", {
library(logspline)
library(KernSmooth)
library(mclust)
set.seed(333)
x <- distribution_normal(500, 1)
# Methods
density_kernel <- estimate_density(x, method = "kernel")
density_logspline <- estimate_density(x, method = "logspline")
density_KernSmooth <- estimate_density(x, method = "KernSmooth")
density_mixture <- estimate_density(x, method = "mixture")
testthat::expect_equal(mean(density_kernel$y - density_logspline$y), 0, tol = 0.1)
testthat::expect_equal(mean(density_kernel$y - density_KernSmooth$y), 0, tol = 0.1)
testthat::expect_equal(mean(density_kernel$y - density_mixture$y), 0, tol = 0.1)
})
}