[英]Extract the full p.value from chisq.test
從 R 中的 chisq.test 得到這個結果。
rslt <- chisq.test(a$x, a$y)
Pearson's Chi-squared test
data: a$x and a$y
X-squared = 32944, df = 9, p-value < 2.2e-16
但提取 p.value 只是 0
> rslt$p.value
[1] 0
我希望得到 2.2e-16 而不是 0。
我還嘗試取消列出 rslt。
> unlist(rslt)
statistic.X-squared parameter.df p.value method
"32943.9488257678" "9" "0" "Pearson's Chi-squared test"
但我仍然得到 0 而不是 2.2e-16。
有沒有辦法從描述或實際值而不是縮短值中獲取信息?
謝謝。
rslt = chisq.test(cbind(c(10,20),c(30,40)))
Pearson's Chi-squared test with Yates' continuity correction
data: cbind(c(10, 20), c(30, 40))
X-squared = 0.44643, df = 1, p-value = 0.504
我們總是可以使用來自測試的卡方估計,並計算 p.value。 使用上面的示例,您可以看到它們是相同的。
rslt$p.value == pchisq(rslt$statistic,rslt$parameter,lower.tail=FALSE)
X-squared
TRUE
使用您的示例,由於 p.value 非常小,請使用日志:
pchisq(32943.9488257678,9,lower.tail=F,log.p=TRUE)
-16440.44
您的 p 值似乎為零,即: < 2.2e-16
。 或小於 R 可以處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.