从 Coin Packages 的对象 QuadTypeIndependenceTest 和 ScalarIndependenceTest 中提取 p 值

Extract p-value from an Object QuadTypeIndependenceTest and ScalarIndependenceTest from Coin Packages

使用包 MASS 中的 Aids2 数据集,我正在应用 Ansari-Bradley 非参数测试通过此片段测试组独立性

library(coin)
library(MASS)
a1 <- ansari_test(Aids2$diag~Aids2$state)
a2 <- ansari_test(Aids2$diag~Aids2$sex)

如果我看一下 a1 和 a2 对象,它会给出如下摘要:

Asymptotic K-Sample Ansari-Bradley Test

data:  Aids2$diag by Aids2$state (NSW, Other, QLD, VIC)
chi-squared = 4.4829, df = 3, p-value = 0.2138

Asymptotic Two-Sample Ansari-Bradley Test

data:  Aids2$diag by Aids2$sex (F, M)
Z = -1.6765, p-value = 0.09364
alternative hypothesis: true ratio of scales is not equal to 1

与各自的对象 class 是:

> class(a1)
[1] "QuadTypeIndependenceTest"
attr(,"package")
[1] "coin"
> class(a2)
[1] "ScalarIndependenceTest"
attr(,"package")
[1] "coin"

然而,由于我只对 p 值 (p-value = 0.2138) 感兴趣,我只想从对象中提取它,但我找不到如何提取它..

由于 "QuadTypeIndependenceTest""ScalarIndependenceTest" 等对象是根据 coin 包的结果创建的,因此有使用 coin::pvalue(obj) 提取 pvalue 的特定函数,特别感谢指向@AntoniosK