[R] Chi-squared test

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Nov 25 11:06:08 CET 2005


On 25-Nov-05 Marc Schwartz wrote:
> On Thu, 2005-11-24 at 21:55 +0000, Ted Harding wrote:
>> I'm rather with Peter on this question! I've tried to infer what
>> you're really trying to do.
>> 
>> My a-priori plausible hypothesis was that you have
>> 
>>   k<-12
>> 
>> independent observations which have equal expected values
>> 
>>   m<-rep(80,k)
>> 
>> and are observed as
>> 
>>   x<-c(79,52,69,71,82,87,95,74,55,78,49,60)
>> 
>> On this basis, a chi-squared test Sum((O-E)^2/E) gives
>> 
>>   C2<-sum(((x-m)^2)/m)
>> 
>> so C2 = 41.1375, and on this hypothesis the chi-squared would
>> have k=12 degrees of freedom. Then:
>> 
>>   1-pchisq(C2,k)
>> ## [1] 4.647553e-05
>>[...]
> 
> It's late on Turkey Day here, but shouldn't that be:
> 
>> 1 - pchisq(C2, k - 1)  # 11 df
> [1] 2.282202e-05

I don't think so ... I was trying to guess at a "chi=squareed"
scenario which included, in particular, the feature that the
observed do not sum to the same value as the expected. So I tried
the case in the 12 expected values have been given (in this case
all "80"), and the 12 independent observed values are to be compared
with them. This is 12 independent comparisons, and there is nothing
to be fitted, and no overall constraint on the observed values.
Hence 12 d.f.

> [...]
> Lastly, I get the same results on my wife's computer using Excel 2002
> and the CHITEST function, so Bianca may want to check for typos in the
> Excel sheet, or the possibility that the wrong syntax was used in the
> CHITEST function formula (ie. wrong cell range, etc.).
> 
> Lacking that, I too am confuzzled as to where the 1.65778E-14 comes
> from.

Confuzzled indeed ... ! Not gallopavated, though :)

Best wishes,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 25-Nov-05                                       Time: 10:06:06
------------------------------ XFMail ------------------------------




More information about the R-help mailing list