[R] Chi-Square Test Disagreement

Chuck Cleland ccleland at optonline.net
Wed Nov 26 16:17:32 CET 2008


On 11/26/2008 9:51 AM, Andrew Choens wrote:
> I was asked by my boss to do an analysis on a large data set, and I am
> trying to convince him to let me use R rather than SPSS. I think Sweave
> could make my life much much easier. To get me a little closer to this
> goal, I ran my analysis through R and SPSS and compared the resulting
> values. In all but one case, they were the same. Given the matrix
> 
>     [,1] [,2]
> [1,]  110  358
> [2,]   71  312
> [3,]   29  139
> [4,]   31   77
> [5,]   13   32
> 
> This is the output from R:
>> chisq.test(test29)
> 
> 	Pearson's Chi-squared test
> 
> data:  test29
> X-squared = 9.593, df = 4, p-value = 0.04787
> 
> But, the same data in SPSS generates a p value of .051. It's a small but
> important difference. I played around and rescaled things, and tried
> different values for B, but I never could get R to reach .051.
> 
> I'd like to know which program is correct - R or SPSS? I know, this is a
> biased place to ask such a question. I also appreciate all input that
> will help me use R more effectively. The difference could be the result
> of my own ignorance.

  The SPSS p-value is for the Likelihood Ratio Chi-squared test, not
Pearson's.  For Pearson's Chi-squared test in SPSS (16.0.2), I get
p=0.04787, so the results do match if you do the same Chi-squared test.

> thanks
> --andy 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list