tests/testthat/test-inliers-versus-outliers.R

suppressPackageStartupMessages({
  library(dsos)
  library(testthat)
})

set.seed(123456)
n <- 1e4
alpha <- 0.05
test_that("Inliers", {
  tr <- rlnorm(n, sdlog = 1)
  te <- rlnorm(n, sdlog = 1 / 2)
  expect_gt(at_from_os(tr, te)$p_value, alpha)
})

test_that("Outliers", {
  tr <- rlnorm(n, sdlog = 1)
  te <- rlnorm(n, sdlog = 3 / 2)
  expect_lt(at_from_os(tr, te)$p_value, alpha)
})

test_that("Same distribution", {
  tr <- rlnorm(n)
  te <- rlnorm(n)
  expect_gt(at_from_os(tr, te)$p_value, alpha)
})

Try the dsos package in your browser

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

dsos documentation built on March 7, 2023, 6:47 p.m.