Skip to content

Commit 2646f9a

Browse files
authored
Merge pull request #975 from galafis/fix/wald-upper-tail
BUG: Preserve small upper-tail Wald p-values
2 parents 53888db + 806d630 commit 2646f9a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎arch/tests/utility/test_validation_utility.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ def test_wald_values():
607607
assert WaldTestStatistic(np.inf, 1, "a", "b").pval == 0.0
608608

609609

610+
@pytest.mark.parametrize("stat", [50.0, 100.0, 500.0, 1000.0])
611+
def test_wald_pvalue_upper_tail(stat):
612+
wald = WaldTestStatistic(stat, 2, "a", "b")
613+
# For two degrees of freedom the upper tail has this closed form.
614+
assert_allclose(wald.pval, np.exp(-stat / 2), rtol=1e-12, atol=0)
615+
616+
610617
def test_formats():
611618
assert str_format(np.nan) == " "
612619
assert str_format(np.inf) == " inf"

‎arch/utility/testing.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def stat(self) -> float:
6060
@cached_property
6161
def pval(self) -> float:
6262
"""P-value of test statistic."""
63-
return 1 - self.dist.cdf(self.stat)
63+
return self.dist.sf(self.stat)
6464

6565
@cached_property
6666
def critical_values(self) -> dict[str, float]:

0 commit comments

Comments
 (0)