2

我有表格形式的数据,

y <- structure(c(1644L, 4031L, 2276L, 2610L, 1110L, 885L, 315L, 97L, 
50L, 33L, 32L, 14L, 18L, 25L, 73L, 74L, 101L, 63L, 62L, 16L, 
6L, 2L, 1L, 1L, 0L, 8L, 9L, 23L, 13L, 13L, 8L, 3L, 3L, 0L, 0L, 
0L, 0L, 2L, 1L, 7L, 0L, 2L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 
0L, 0L, 1L, 1L, 0L), .Dim = 56L, .Dimnames = structure(list(c("0", 
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", 
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", 
"24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", 
"35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", 
"46", "47", "48", "49", "50", "51", "52", "53", "54", "more")), .Names = ""), class = "table")

以及以下形式的概率分布表,

p1 <- structure(c(0.057521136002127, 0.164257517951512, 0.234527115411922, 
0.223238763738751, 0.159370310597375, 0.0910196615481254, 0.0433193336391715, 
0.0176718301615021, 0.00630796599679829, 0.00200144949601812, 
0.000571534481706143, 0.000148370497767644, 3.5307267603979e-05, 
7.75565636906458e-06, 1.58193386914368e-06, 3.01158320771418e-07, 
5.37492843049567e-08, 9.02862397783854e-09, 1.43234244757772e-09, 
2.15273743520359e-10, 3.07368154111881e-11, 4.17962555454137e-12, 
5.42515931985809e-13, 6.73569575280125e-14, 8.01436323330177e-15, 
9.15433528722608e-16, 1.00542867790378e-16, 1.06337220888322e-17, 
1.08448881222248e-18, 1.06788596764981e-19, 1.01648605882263e-20, 
9.36348532927413e-22, 8.35574846079783e-23, 7.23051479850592e-24, 
6.07278777067245e-25, 4.95470567410246e-26, 3.93018652105282e-27, 
3.03325721546454e-28, 2.27941522272648e-29, 1.66900116128775e-30, 
1.19150110405147e-31, 8.29866806850226e-33, 5.64230950144948e-34, 
3.74702207011776e-35, 2.43181972166451e-36, 1.54318027674935e-37, 
9.57980422608031e-39, 5.82045019690281e-40, 3.46268624439587e-41, 
2.01797073279214e-42, 1.15250458146367e-43, 6.45312809483737e-45, 
3.54376360771359e-46, 1.90935496937575e-47, 1.00969619026602e-48, 
0), .Names = c("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", 
"21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", 
"32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", 
"43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", 
"54", "more"))

当我尝试运行 chisq.test 时chisq.test(y, p = p1)。我得到 pvalues = NA。谁能向我解释为什么会这样?

    Chi-squared test for given probabilities

data:  y
X-squared = NaN, df = 55, p-value = NA

Warning message:
In chisq.test(y, p = p1) : Chi-squared approximation may be incorrect
4

2 回答 2

1

chisq 的公式是 sum( (oe)^2/e ) 您的尾随概率为 0,由于除以 0 而产生无穷大。试试这个:

> chisq.test(x=y[-56], p=p1[-56], correct=FALSE)

    Chi-squared test for given probabilities

data:  y[-56]
X-squared = 7.647192e+43, df = 54, p-value < 2.2e-16
于 2013-09-08T15:28:40.423 回答
0

Maybe it's because of the zeroes in your observed data.

See here:

https://stats.stackexchange.com/questions/10053/nan-p-value-when-using-rs-goodfit-on-binomial-data

于 2013-09-08T08:02:20.510 回答