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 113 114 115 116 117 118 119 120 121 122 123
|
skip_if_not_installed("metaBMA")
data(towels, package = "metaBMA")
set.seed(1234)
m <- suppressWarnings(
metaBMA::meta_random(
logOR,
SE,
study,
data = towels,
ci = 0.95,
iter = 100,
logml_iter = 200
)
)
test_that("model_parameters.meta_random", {
params <- model_parameters(m)
expect_identical(
params$Parameter,
c(
"Goldstein, Cialdini, & Griskevicius (2008), Exp. 1", "Goldstein, Cialdini, & Griskevicius (2008), Exp. 2",
"Schultz, Khazian, & Zaleski (2008), Exp. 2", "Schultz, Khazian, & Zaleski (2008), Exp. 3",
"Mair & Bergin-Seers (2010), Exp. 1", "Bohner & Schluter (2014), Exp. 1",
"Bohner & Schluter (2014), Exp. 2", "Overall", "tau"
)
)
expect_equal(
params$Coefficient,
c(0.3806, 0.30494, 0.20554, 0.25084, 0.28768, -0.12154, -1.45792, 0.2004, 0.12107),
tolerance = 1e-3
)
expect_equal(
params$CI_low,
c(-0.00686, 0.03816, -0.16998, -0.0825, -1.32685, -0.60772, -2.94785, -0.02744, 0.02641),
tolerance = 1e-3
)
expect_identical(
colnames(params),
c(
"Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Weight",
"BF", "Rhat", "ESS", "Component", "Prior_Distribution", "Prior_Location", "Prior_Scale", "Method"
)
)
})
set.seed(1234)
m2 <- metaBMA::meta_fixed(
logOR,
SE,
study,
data = towels,
ci = 0.95
)
test_that("model_parameters.meta_fixed", {
params <- model_parameters(m2)
expect_identical(params$Parameter, c(
"Goldstein, Cialdini, & Griskevicius (2008), Exp. 1", "Goldstein, Cialdini, & Griskevicius (2008), Exp. 2",
"Schultz, Khazian, & Zaleski (2008), Exp. 2", "Schultz, Khazian, & Zaleski (2008), Exp. 3",
"Mair & Bergin-Seers (2010), Exp. 1", "Bohner & Schluter (2014), Exp. 1",
"Bohner & Schluter (2014), Exp. 2", "Overall"
))
expect_equal(params$Coefficient,
c(0.3806, 0.30494, 0.20554, 0.25084, 0.28768, -0.12154, -1.45792, 0.22141),
tolerance = 1e-3
)
expect_equal(
params$CI_low,
c(-0.00686, 0.03816, -0.16998, -0.0825, -1.32685, -0.60772, -2.94785, 0.06839),
tolerance = 1e-3
)
expect_identical(
colnames(params),
c(
"Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Weight",
"BF", "Rhat", "ESS", "Component", "Prior_Distribution", "Prior_Location", "Prior_Scale", "Method"
)
)
})
set.seed(1234)
m3 <- suppressWarnings(
metaBMA::meta_random(
logOR,
SE,
study,
data = towels,
ci = 0.99,
iter = 100,
logml_iter = 200
)
)
test_that("model_parameters.meta_random", {
params <- model_parameters(m3)
expect_identical(
params$Parameter,
c(
"Goldstein, Cialdini, & Griskevicius (2008), Exp. 1", "Goldstein, Cialdini, & Griskevicius (2008), Exp. 2",
"Schultz, Khazian, & Zaleski (2008), Exp. 2", "Schultz, Khazian, & Zaleski (2008), Exp. 3",
"Mair & Bergin-Seers (2010), Exp. 1", "Bohner & Schluter (2014), Exp. 1",
"Bohner & Schluter (2014), Exp. 2", "Overall", "tau"
)
)
expect_equal(
params$Coefficient,
c(0.3806, 0.30494, 0.20554, 0.25084, 0.28768, -0.12154, -1.45792, 0.2004, 0.12107),
tolerance = 1e-3
)
expect_equal(
params$CI_low,
c(-0.00686, 0.03816, -0.16998, -0.0825, -1.32685, -0.60772, -2.94785, -0.15494, 0.01993),
tolerance = 1e-3
)
expect_identical(
colnames(params),
c(
"Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Weight",
"BF", "Rhat", "ESS", "Component", "Prior_Distribution", "Prior_Location", "Prior_Scale", "Method"
)
)
})
|