1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
test_that("p_value", {
expect_equal(p_value(c(1, 1, 1)), p_value(-c(1, 1, 1)), tolerance = 1e-3)
set.seed(123)
x <- rnorm(100, mean = 1.5)
expect_equal(p_value(x), p_value(-x), tolerance = 1e-3)
expect_gt(p_value(x, null = 1), p_value(x))
expect_gt(p_value(x), p_value(x, null = -1))
expect_equal(p_value(x, null = -1), p_value(-x, null = 1), tolerance = 1e-3)
})
skip_on_cran()
test_that("p_value", {
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr2")
skip_if_not_installed("lme4")
# h-tests
model <- insight::download_model("htest_1")
expect_equal(p_value(model), 0.04136799, tolerance = 0.01)
model <- insight::download_model("htest_2")
expect_equal(p_value(model), 0.1518983, tolerance = 0.01)
model <- insight::download_model("htest_3")
expect_equal(p_value(model), 0.182921, tolerance = 0.01)
model <- insight::download_model("htest_4")
expect_equal(p_value(model), 0, tolerance = 0.01)
model <- insight::download_model("htest_5")
expect_equal(p_value(model), 0, tolerance = 0.01)
model <- insight::download_model("htest_6")
expect_equal(p_value(model), 0, tolerance = 0.01)
model <- insight::download_model("htest_7")
expect_equal(p_value(model), 0, tolerance = 0.01)
model <- insight::download_model("htest_8")
expect_equal(p_value(model), 0, tolerance = 0.01)
# ANOVAs
model <- insight::download_model("aov_1")
expect_equal(p_value(model)$p, 0, tolerance = 0.01)
model <- insight::download_model("anova_1")
expect_equal(p_value(model)$p, 0, tolerance = 0.01)
model <- insight::download_model("aovlist_1")
expect_equal(p_value(model)$p, 0, tolerance = 0.01)
model <- insight::download_model("aov_2")
expect_equal(p_value(model)$p[1], 0, tolerance = 0.01)
model <- insight::download_model("anova_2")
expect_equal(p_value(model)$p[1], 0, tolerance = 0.01)
model <- insight::download_model("aovlist_2")
expect_equal(p_value(model)$p[1], 0, tolerance = 0.01)
model <- insight::download_model("aov_3")
expect_equal(p_value(model)$p[1], 0, tolerance = 0.01)
model <- insight::download_model("anova_3")
expect_equal(p_value(model)$p[1], 0, tolerance = 0.01)
model <- insight::download_model("aovlist_3")
expect_equal(p_value(model)$p[1], 0, tolerance = 0.01)
model <- insight::download_model("anova_4")
expect_equal(p_value(model)$p[2], 0, tolerance = 0.01)
# ANOVA lmer
model <- insight::download_model("anova_lmerMod_0")
expect_identical(p_value(model), NA)
model <- insight::download_model("anova_lmerMod_1")
expect_identical(p_value(model), NA)
model <- insight::download_model("anova_lmerMod_2")
expect_identical(p_value(model), NA)
model <- insight::download_model("anova_lmerMod_3")
expect_identical(p_value(model), NA)
model <- insight::download_model("anova_lmerMod_4")
expect_identical(p_value(model), NA)
model <- insight::download_model("anova_lmerMod_5")
expect_identical(p_value(model), NA)
model <- insight::download_model("anova_lmerMod_6")
expect_equal(p_value(model)$p[2], 0, tolerance = 0.01)
# Mixed models
model <- lme4::lmer(wt ~ cyl + (1 | gear), data = mtcars)
expect_equal(p_value(model)$p[1], 0.206219, tolerance = 0.01)
expect_equal(p_value(model, method = "normal")$p[1], 0.1956467, tolerance = 0.01)
expect_equal(p_value(model, method = "kr")$p[1], 0.319398, tolerance = 0.01)
model <- insight::download_model("merMod_1")
expect_equal(p_value(model)$p[1], 0.06578, tolerance = 0.01)
model <- insight::download_model("merMod_2")
expect_equal(p_value(model)$p[1], 0.29912, tolerance = 0.01)
})
|