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)A hypothesis_test object with "complemented_test" prepended
to the class vector. The original class hierarchy is preserved.
The pre-complement p-value
The input test object
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.
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.
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)))