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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
context("check if inconsistencies/errors are correctly classified")
# test if the following cases are correctly identified as errors --------------
# check classification of regular errors in all types of tests
test_that("simple errors are classified as such", {
txt1 <- "t(28) = 2.20, p = .03"
txt2 <- "F(2, 28) = 2.20, p = .15"
txt3 <- "r(28) = .22, p = .26"
txt4 <- "chi2(28) = 22.20, p = .79"
txt5 <- " z = 2.20, p = .04"
txt6 <- "Q(28) = 22.20, p = .79"
expect_true(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt4, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt5, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt6, messages = FALSE)[[VAR_ERROR]])
})
# classify p-values of negative test statistics correctly
test_that("p-values of negative tests are correctly classified", {
txt1 <- " Z = -2.42, p = 0.016" # no error
txt2 <- "t(28) = -2.20, p = .03" # error
expect_false(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
})
# classify inexactly reported p-values correctly
test_that("inexactly reported p-values are correctly classified",{
txt1 <- "t(28) = 2.20, ns"
txt2 <- "t(28) = 2.20, p > .05"
txt3 <- "t(28) = 2.0, p < .05"
expect_true(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
})
# also classify decision errors as errors
test_that("decision errors are also classified as errors",{
txt1 <- "t(28) = 1.20, p = .03"
txt2 <- "t(28) = 2.20, p = .30"
expect_true(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
})
# test if the following cases are correctly identified as correct -------------
# correct rounding
test_that("correctly rounded p-values are not considered errors", {
txt1 <- "t(28) = 2, p = .02"
txt2 <- "t(28) = 2, p = .14"
txt3 <- "t(28) = 2.2, p = .03" # rounded lower bound p-value
txt4 <- "t(28) = 2.2, p = .04"
txt5 <- "t(28) = 2.20, p = .036"
txt6 <- "t(28) = 2.20, p = .037"
expect_false(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt4, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt5, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt6, messages = FALSE)[[VAR_ERROR]])
})
# test if different arguments concerning errors work --------------------------
# OneTailedTests: assume all tests are one-tailed
test_that("OneTailedTests considers everything as one-tailed", {
txt1 <- "t(28) = 2.20, p = .02"
txt2 <- "t(28) = 2.20, p = .04"
txt3 <- "this test is one-tailed: t(28) = 2.20, p = .02, but this one is not: t(28) = 2.20, p = .04"
expect_false(statcheck(txt1, messages = FALSE, OneTailedTests = TRUE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE, OneTailedTests = TRUE)[[VAR_ERROR]])
expect_equal(statcheck(txt3, messages = FALSE, OneTailedTests = TRUE)[[VAR_ERROR]], c(FALSE, TRUE))
})
# OneTailedTxt: automated detection of one-tailed test in text
test_that("automated one-tailed test detection works", {
txt1 <- "t(28) = 2.20, p = .018"
txt2 <- "t(28) = 2.20, p = .01, one-tailed"
txt3 <- "t(28) = 2.20, p = .018, one-tailed"
txt4 <- "t(28) = 2.20, p = .018, one-sided"
txt5 <- "t(28) = 2.20, p = .018, directional"
# don't correct for one-tailed testing here
expect_true(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt1, messages = FALSE, OneTailedTxt = TRUE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE, OneTailedTxt = TRUE)[[VAR_ERROR]])
expect_true(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
# correct for one-tailed testing here
expect_false(statcheck(txt3, messages = FALSE, OneTailedTxt = TRUE)[[VAR_ERROR]])
expect_false(statcheck(txt4, messages = FALSE, OneTailedTxt = TRUE)[[VAR_ERROR]])
expect_false(statcheck(txt5, messages = FALSE, OneTailedTxt = TRUE)[[VAR_ERROR]])
# check that p-values were corrected in these cases
p_1tail <- pt(2.20, 28, lower.tail = FALSE)
expect_equal(statcheck(c(txt3, txt4, txt5), messages = FALSE,
OneTailedTxt = TRUE)[[VAR_COMPUTED_P]], rep(p_1tail, 3))
})
# pZeroError: check if p = .000 is counted as an inconsistency or not
test_that("you can adapt whether p = .000 is counted as inconsistent or not", {
txt1 <- "t(28) = 22.20, p = .000"
txt2 <- "t(28) = 22.20, p < .000" # this is always an Error
expect_true(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt1, messages = FALSE, pZeroError = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt2, messages = FALSE, pZeroError = FALSE)[[VAR_ERROR]])
})
# test classifications of (in)exact test statistcs and (in)exact p-values ----
# test statistics exactly reported
test_that("cases where t = ... are correctly classified", {
# calculate range of correct p-values
lowp <- pt(2.25, 28, lower.tail = FALSE)*2
upp <- pt(2.15, 28, lower.tail = FALSE)*2
# correct
txt1 <- "t(28) = 2.2, p = .036" # correct
txt2 <- "t(28) = 2.2, p < .08" # correct
txt3 <- "t(28) = 2.2, p > .02" # correct
# error
txt4 <- paste("t(28) = 2.2, p >", upp) # error
txt5 <- paste("t(28) = 2.2, p <", lowp) # error
txt6 <- "t(28) = 2.2, p = .08" # error
txt7 <- "t(28) = 2.2, p = .02" # error
txt8 <- "t(28) = 2.2, p > .08" # error
txt9 <- "t(28) = 2.2, p < .02" # error
expect_false(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt4, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt5, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt6, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt7, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt8, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt9, messages = FALSE)[[VAR_ERROR]])
})
# test statistic reported as <
test_that("cases where t < ... are correctly classified", {
# calculate range of correct p-values
lowp <- pt(2.25, 28, lower.tail = FALSE)*2
upp <- pt(2.15, 28, lower.tail = FALSE)*2
# correct
txt1 <- paste("t(28) < 2.20, p >", upp)
txt2 <- "t(28) < 2.2, p = .08"
txt3 <- "t(28) < 2.2, p > .08"
txt4 <- "t(28) < 2.2, p < .08"
txt5 <- "t(28) < 2.2, p > .02"
# error
txt6 <- paste("t(28) < 2.2, p =", lowp)
txt7 <- paste("t(28) < 2.2, p <", lowp)
txt8 <- "t(28) < 2.2, p < .02"
txt9 <- "t(28) < 2.2, p = .02"
expect_false(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt4, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt5, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt6, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt7, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt8, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt9, messages = FALSE)[[VAR_ERROR]])
})
# test statistic reported as >
test_that("cases where t > ... are correctly classified", {
# calculate range of correct p-values
lowp <- pt(2.25, 28, lower.tail = FALSE)*2
upp <- pt(2.15, 28, lower.tail = FALSE)*2
# correct
txt1 <- paste("t(28) > 2.20, p <", upp)
txt2 <- "t(28) > 2.2, p = .02"
txt3 <- "t(28) > 2.2, p > .02"
txt4 <- "t(28) > 2.2, p < .02"
txt5 <- "t(28) > 2.2, p < .08"
# error
txt6 <- paste("t(28) > 2.2, p =", upp)
txt7 <- paste("t(28) > 2.2, p >", upp)
txt8 <- "t(28) > 2.2, p > .08"
txt9 <- "t(28) > 2.2, p = .08"
expect_false(statcheck(txt1, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt2, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt3, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt4, messages = FALSE)[[VAR_ERROR]])
expect_false(statcheck(txt5, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt6, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt7, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt8, messages = FALSE)[[VAR_ERROR]])
expect_true(statcheck(txt9, messages = FALSE)[[VAR_ERROR]])
})
|