Negates a hypothesis test by transforming its p-value: \(p \to 1 - p\). The complement test rejects when the original test fails to reject.

complement_test(test)

Arguments

test

A hypothesis_test object.

Value

A hypothesis_test object with "complemented_test" prepended to the class vector. The original class hierarchy is preserved.

original_pval

The pre-complement p-value

original_test

The input test object

Details

The complement is the NOT operation in the Boolean algebra of hypothesis tests. Together with intersection_test() (AND) and union_test() (OR), it forms a complete algebra where De Morgan's laws hold by construction.

Connection to Equivalence Testing

If the original test checks "is \(\theta\) different from \(\theta_0\)?" (rejecting when the difference is large), the complement checks "is \(\theta\) close to \(\theta_0\)?" (rejecting when the difference is small). This connects to the Two One-Sided Tests (TOST) procedure used in bioequivalence studies.

Algebraic Properties

  • Double complement is identity: complement_test(complement_test(t)) has the same p-value as t

  • De Morgan's law: union_test(a, b) = complement_test(intersection_test(complement_test(a), complement_test(b)))

Examples

w <- wald_test(estimate = 3.0, se = 1.0)
pval(w)                  # small
#> [1] 0.002699796
pval(complement_test(w)) # large
#> [1] 0.9973002

# Double complement recovers the original
pval(complement_test(complement_test(w))) == pval(w)
#> [1] FALSE