# Getting different result of Chi-squared from R vs book or online calculator

Calculating Chi-squared using R gives me different results vs what the book shows or what I get from Online calculator.

The data and the way it is arranged in the table seem correct, but the answer I get is different.

We use R in our exams, and I am not sure why I am getting a different answer.

x=matrix(c(18,5,33,42), nrow=2, ncol=2)
x
chisq.test(x,correct=T)

x=matrix(c(18,5,33,42), nrow=2, ncol=2)
x
[,1] [,2]
[1,] 18 33
[2,] 5 42
chisq.test(x,correct=T)

Pearson's Chi-squared test with Yates' continuity correction


data: x
X-squared = 6.9625, df = 1, p-value = 0.008323

The correct answer is: X-squared= 8.2784, p-value=0.00412 (the book and online calculator have the same answer)

In 1976, statisticians at Bell Labs began to develop S as a language for statistical programming at Bell Labs. and in 1991 development continued as the open-source project R. R is now a mature language that implements many new and all standard statistical tests. The \chi^2 test dates to 1900. The question should be reframed not as why R results differ from an unnamed book and an unnamed calculator but why those sources differ from R.

One possibility is that the unnamed sources are run without the Yates continuity correction. Try

(Xsq <- chisq.test(x, correct = FALSE))

1 Like

Thanks.

The textbook also uses R. My main problem is identifying what I may have been doing wrong, since the answer I get using R is different.

chisq.test(x,correct=False)
(Xsq=chisq.test(x,correct=False))

FALSE needs to be capitalized.

1 Like

Thank you!!

Pearson's Chi-squared test


data: x
X-squared = 8.2784, df = 1, p-value = 0.004012

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.