作者nearfly (細枝小葉)
看板NCU97Stat
標題[轉錄][統算] chisq.test
時間Sat Jun 6 16:24:45 2009
※ [本文轉錄自 NCU96Stat 看板]
作者: Chris7462 (~烤焦麵包~) 看板: NCU96Stat
標題: Re: [統算] chisq.gof()
時間: Wed Jun 4 00:48:56 2008
# chisq.test.r
- rescale.p = FALSE, simulate.p.value = FALSE, B = 2000)
+ rescale.p = FALSE, simulate.p.value = FALSE, B = 2000, unspec.m = 0)
else {
- PARAMETER <- length(x) - 1
+ if(unspec.m){
+ PARAMETER <- length(x) - unspec.m - 1
+ }
+ else {
+ PARAMETER <- length(x) - 1
+ }
PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
}
## Example 9c ##
> N <- c(6, 2, 1, 9, 7, 5)
> prob <- c(0.0550, 0.1596, 0.2312, 0.2237, 0.1622, 0.1682)
> chisq.test(N, p=prob, unspec.m=1)
Chi-squared test for given probabilities
data: N
X-squared = 19.887, df = 4, p-value = 0.0005257
Warning message:
In chisq.test(N, p = p, unspec.m = 1) :
Chi-squared approximation may be incorrect
--
改一下 chisq.test 的函式,加入一個 unspec.m(unspecified parameter 的個數)
這樣跑出來的結果就跟 Example 9c 一樣了,也就是我們要的 goodness of fit :p
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.221.212
※ 編輯: Chris7462 來自: 140.115.221.212 (06/04 01:25)
1F:推 anniecs:好厲害 06/04 12:47
2F:推 yayacy:真的超強的!!!感恩感恩 06/05 01:25
3F:推 luckyb:感激Q__Q 06/05 14:58
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.161.197.102
4F:→ nearfly:學長3q~ 06/06 16:34
5F:推 Chris7462:不客氣。突然看到自己 po 的文還滿奇怪的 = = 06/06 21:05
6F:推 ricindy:太感謝了~!! 06/07 23:17