Skip to content
Prev 312848 / 398506 Next

Chi-squared test when observed near expected

On 03-Dec-2012 21:40:35 Troy S wrote:
being zero in this case?
The reason is that (by default, see ?chisq.test ) the statistic
is caluclated using the "continuity correction" (1/2 is subtracted
from each abs(O-E) difference). The default setting in chisq.test()
is "correct = TRUE". Try it with "correct = FALSE":

  x0<-chisq.test(trial,correct=FALSE)
  x0
  #      Pearson's Chi-squared test
  # data:  trial 
  # X-squared = 0.0556, df = 1, p-value = 0.8136

which agrees with your calculation of

  sum((x$observed-x$expected)^2/x$expected)
  # [1] 0.05562457

Hoping this helps,
Ted.

-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 03-Dec-2012  Time: 22:44:14
This message was sent by XFMail