Different value for Pearson $\chi^2$ in chisq.test() and loglm() from MASS I realized that the Pearson's $\chi^2$ statistic obtained by chisq.test() is different than the one obtained using loglm() from MASS. Why is this so? For instance: 
require(MASS)
k <- matrix(c(15,4,3,10), ncol=2)
loglm(~1+2, k)$pearson
chisq.test(k)$statistic

 A: The difference is the continuity correction (Yates' correction) that chisq.test applies by default to 2x2 tables. See ?chisq.test.
The discreteness of the chi-square statistic makes the continuous asymptotic chi-square approximation relatively inaccurate in some cases; the continuity correction tends to improve the approximation.
For discussion of how this corrected calculation is done, see the explanation in the Wikipedia article on Yates' correction
If you use the option that stops it applying the correction, you get the same result as loglm
chisq.test(k,correct=FALSE)$statistic
X-squared 
 9.79063 

For larger tables, no correction is made in R, and the results are the same with default settings (aside from the warning; NB this data set is in MASS):
> loglm(~ Type + Origin, xtabs(~ Type + Origin, Cars93))
Call:
loglm(formula = ~Type + Origin, data = xtabs(~Type + Origin, 
    Cars93))

Statistics:
                      X^2 df   P(> X^2)
Likelihood Ratio 18.36179  5 0.00252554
Pearson          14.07985  5 0.01511005

vs
> chisq.test(xtabs(~Type + Origin, Cars93))

        Pearson's Chi-squared test

data:  xtabs(~Type + Origin, Cars93)
X-squared = 14.08, df = 5, p-value = 0.01511

Warning message:
In chisq.test(xtabs(~Type + Origin, Cars93)) :
  Chi-squared approximation may be incorrect

