tests/testthat/test-PACKAGE.R

context("basic functionality")
test_that("we can do something", {

  structure(list(method = c("fs", "fs", "fs", "fs", "fs", "fs",
"goodman", "goodman", "goodman", "goodman", "goodman", "goodman",
"qh", "qh", "qh", "qh", "qh", "qh", "sg", "sg", "sg", "sg", "sg",
"sg", "wald", "wald", "wald", "wald", "wald", "wald", "waldcc",
"waldcc", "waldcc", "waldcc", "waldcc", "waldcc", "wilson", "wilson",
"wilson", "wilson", "wilson", "wilson"), lower_limit = c(0.0830625766484,
0.11754533526909, 0.0799277804101555, 0.0454450217894659, 0.155162890128024,
0.189645648748714, 0.0946836803518434, 0.123768933872965, 0.0920852700225933,
0.0641267104678176, 0.156379436074963, 0.186927316249989, 0.0857664713234835,
0.113355123114891, 0.0833139904101309, 0.0570912005173716, 0.144527539314625,
0.173905203726289, 0.0846, 0.1191, 0.0815, 0.047, 0.1567, 0.1912,
0.100090718734925, 0.130961804067036, 0.0973204449143323, 0.0673465877293442,
0.165332149226147, 0.197349318323633, 0.0985233206158029, 0.129394405947913,
0.0957530467952101, 0.0657791896102219, 0.163764751107025, 0.195781920204511,
0.104378824785799, 0.134923115979524, 0.101636996560702, 0.07195583916023,
0.168915427427959, 0.200572307958597), upper_limit = c(0.192799492317117,
0.227282250937807, 0.189664696078873, 0.155181937458183, 0.264899805796741,
0.299382564417431, 0.19664128127306, 0.235048888549567, 0.193103976984344,
0.153569675741492, 0.276066961763164, 0.313011942385766, 0.214383037299087,
0.253446813257911, 0.210776206598783, 0.170346568741311, 0.294986136422066,
0.332260899760634, 0.1929, 0.2273, 0.1897, 0.1552, 0.265, 0.2994,
0.175771350230592, 0.213865782139861, 0.172272031574696, 0.133280371518305,
0.254730546698618, 0.291678894842511, 0.177338748349714, 0.215433180258983,
0.173839429693818, 0.134847769637427, 0.25629794481774, 0.293246292961633,
0.180099690322457, 0.217700302451755, 0.17664652733637, 0.138182781413818,
0.258047885537527, 0.294535908329912), adj_ll = c(0.0830625766484,
0.11754533526909, 0.0799277804101555, 0.0454450217894659, 0.155162890128024,
0.189645648748714, 0.0946836803518434, 0.123768933872965, 0.0920852700225933,
0.0641267104678176, 0.156379436074963, 0.186927316249989, 0.0857664713234835,
0.113355123114891, 0.0833139904101309, 0.0570912005173716, 0.144527539314625,
0.173905203726289, 0.0846, 0.1191, 0.0815, 0.047, 0.1567, 0.1912,
0.100090718734925, 0.130961804067036, 0.0973204449143323, 0.0673465877293442,
0.165332149226147, 0.197349318323633, 0.0985233206158029, 0.129394405947913,
0.0957530467952101, 0.0657791896102219, 0.163764751107025, 0.195781920204511,
0.104378824785799, 0.134923115979524, 0.101636996560702, 0.07195583916023,
0.168915427427959, 0.200572307958597), adj_ul = c(0.192799492317117,
0.227282250937807, 0.189664696078873, 0.155181937458183, 0.264899805796741,
0.299382564417431, 0.19664128127306, 0.235048888549567, 0.193103976984344,
0.153569675741492, 0.276066961763164, 0.313011942385766, 0.214383037299087,
0.253446813257911, 0.210776206598783, 0.170346568741311, 0.294986136422066,
0.332260899760634, 0.1929, 0.2273, 0.1897, 0.1552, 0.265, 0.2994,
0.175771350230592, 0.213865782139861, 0.172272031574696, 0.133280371518305,
0.254730546698618, 0.291678894842511, 0.177338748349714, 0.215433180258983,
0.173839429693818, 0.134847769637427, 0.25629794481774, 0.293246292961633,
0.180099690322457, 0.217700302451755, 0.17664652733637, 0.138182781413818,
0.258047885537527, 0.294535908329912), volume = c(1.75e-06, 1.75e-06,
1.75e-06, 1.75e-06, 1.75e-06, 1.75e-06, 1.55e-06, 1.55e-06, 1.55e-06,
1.55e-06, 1.55e-06, 1.55e-06, 6.2e-06, 6.2e-06, 6.2e-06, 6.2e-06,
6.2e-06, 6.2e-06, 1.61e-06, 1.61e-06, 1.61e-06, 1.61e-06, 1.61e-06,
1.61e-06, 2.6e-07, 2.6e-07, 2.6e-07, 2.6e-07, 2.6e-07, 2.6e-07,
3.3e-07, 3.3e-07, 3.3e-07, 3.3e-07, 3.3e-07, 3.3e-07, 2.6e-07,
2.6e-07, 2.6e-07, 2.6e-07, 2.6e-07, 2.6e-07), inpmat = c(44,
55, 43, 32, 67, 78, 44, 55, 43, 32, 67, 78, 44, 55, 43, 32, 67,
78, 44, 55, 43, 32, 67, 78, 44, 55, 43, 32, 67, 78, 44, 55, 43,
32, 67, 78, 44, 55, 43, 32, 67, 78), alpha = c(0.05, 0.05, 0.05,
0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05,
0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05,
0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05,
0.05, 0.05, 0.05, 0.05, 0.05, 0.05)), .Names = c("method", "lower_limit",
"upper_limit", "adj_ll", "adj_ul", "volume", "inpmat", "alpha"
), row.names = c(NA, -42L), class = c("tbl_df", "tbl", "data.frame"
)) -> all_comp

  y <- c(44, 55, 43, 32, 67, 78)
  z <- 0.05

  res <- scimple_ci(y, z)

  expect_equal(res$method, all_comp$method)
  expect_equal(res$lower_limit, all_comp$lower_limit)
  expect_equal(res$upper_limit, all_comp$upper_limit)
  expect_equal(res$adj_ll, all_comp$adj_ll)
  expect_equal(res$adj_ul, all_comp$adj_ul)
  expect_equal(res$volume, all_comp$volume)

  invisible(scimp_fs(y, z))
  invisible(scimp_goodman(y, z))
  invisible(scimp_qh(y, z))
  invisible(scimp_sg(y, z))
  invisible(scimp_wald(y, z))
  invisible(scimp_waldcc(y, z))
  invisible(scimp_wilson(y, z))

  structure(list(method = c("bmde", "bmde", "bmde", "bmde", "bmde",
"bmde"), lower_limit = c(0.1035, 0.1335, 0.1005, 0.0715, 0.1665,
0.1978), upper_limit = c(0.1783, 0.2156, 0.1742, 0.1364, 0.2547,
0.2911), volume = c(2.4171698498975e-07, 2.4171698498975e-07,
2.4171698498975e-07, 2.4171698498975e-07, 2.4171698498975e-07,
2.4171698498975e-07), mean = c(0.1385, 0.1725, 0.1352, 0.1016,
0.2091, 0.2431)), .Names = c("method", "lower_limit", "upper_limit",
"volume", "mean"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-6L)) -> bmde

  y <- c(44, 55, 43, 32, 67, 78)
  z <- 1

  res <- scimp_bmde(y, z)

  expect_equal(res$method, bmde$method)
  expect_equal(res$lower_limit, bmde$lower_limit)
  expect_equal(res$upper_limit, bmde$upper_limit)
  expect_equal(res$mean, bmde$mean)
  expect_equal(res$volume, bmde$volume)

  structure(list(method = c("bmdu", "bmdu", "bmdu", "bmdu", "bmdu",
"bmdu"), lower_limit = c(0.1024, 0.1324, 0.099, 0.0721, 0.1677,
0.1988), upper_limit = c(0.1372, 0.1711, 0.1337, 0.1025, 0.2107,
0.2449), volume = c(2.47943693419655e-07, 2.47943693419655e-07,
2.47943693419655e-07, 2.47943693419655e-07, 2.47943693419655e-07,
2.47943693419655e-07), mean = c(0.1372, 0.1711, 0.1337, 0.1025,
0.2107, 0.2449)), .Names = c("method", "lower_limit", "upper_limit",
"volume", "mean"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-6L)) -> bmdu

  y <- c(44, 55, 43, 32, 67, 78)
  z <- 2

  res <- scimp_bmdu(y, z)

  expect_equal(res$method, bmdu$method)
  expect_equal(res$lower_limit, bmdu$lower_limit)
  expect_equal(res$upper_limit, bmdu$upper_limit)
  expect_equal(res$mean, bmdu$mean)
  expect_equal(res$volume, bmdu$volume)

})
hrbrmstr/scimple documentation built on April 9, 2020, 9:57 p.m.