Skip to content

Chi-square test

4 messages · pari hesabi, Berend Hasselman, David L Carlson +1 more

#
Hello,
If the vector of observed frequencies is: ?f<-c(0,0,0,2,3,6,17,15,21,21,14,10,5,1,5)
and the vector of probability?:p11<-c(7.577864e-06, 1.999541e-04? ,1.833510e-03,? 9.059845e-03, 2.886977e-02, 6.546229e-02 ,1.124083e-01, 1.525880e-01, 1.689712e-01, 1.563522e-01,?? 1.232031e-01, 8.395000e-02, 5.009534e-02, 2.645857e-02,0.0205403)
The sum of the probabilities is equal to one. But when I want to do the the Chi-square test, I get this error: probabilities must sum to one.
Does anybody know the reason?
Best Regards,
pari
#
print  sum(p11)-1
R FAQ 7.31  (http://cran.r-project.org/doc/FAQ/R-FAQ.html)

Berend
#
And probably why chisq.test has the rescale.p= argument. Your second problem with small expected values can be handled with simulate.p.value=.
Error in chisq.test(f, p = p11) : probabilities must sum to 1.
[1] 4.3036e-08
Chi-squared test for given probabilities

data:  f
X-squared = 7.6268, df = 14, p-value = 0.9078

Warning message:
In chisq.test(f, p = p11, rescale.p = TRUE) :
  Chi-squared approximation may be incorrect
Chi-squared test for given probabilities with simulated p-value (based
        on 2000 replicates)

data:  f
X-squared = 7.6268, df = NA, p-value = 0.7996

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Berend Hasselman
Sent: Friday, February 20, 2015 12:13 PM
To: pari hesabi
Cc: r-help at r-project.org
Subject: Re: [R] Chi-square test
print  sum(p11)-1
R FAQ 7.31  (http://cran.r-project.org/doc/FAQ/R-FAQ.html)

Berend
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
On Feb 20, 2015, at 10:05 AM, pari hesabi wrote:

            
Well, the sum is close to 1.0 but not exact. There's a simple fix:
[1] FALSE
[1] TRUE
Numerical accuracy. See R-FAQ 7.31