Re: [Rd] Chi-squared test (PR#9350)

From: Kasper Daniel Hansen <khansen_at_stat.Berkeley.EDU>
Date: Thu 09 Nov 2006 - 05:44:42 GMT

Upon further reflection on my part I have realized that my original email was way too harsh - even for the sometimes harsh tone on R-devel.

Having spent a few more minutes reflecting on the original question and reading the old thread Robert linked to, it seems that there is indeed some questions about the non-existence of a df argument.

I guess it can be interesting in the case where you are comparing to an estimated probability vector and you want to take that estimation into account (which does not seem straightforward, see Peter Dalgaard's old email). In that case a user might be interested in explicitly passing along a df argument.

On the other hand, there are several circumstances where I would say a df is unnecessary. One case is when the p value is computed by simulation and another is the case where the argument is a matrix and the function tests for independence (at least it would be highly non- standard to have any other degrees of freedom that the usual one).

Since the function returns the statistic it is very easy to directly compute the df by

   statistic = chisq.test( ... )$statistic    p.value = 1 - pchisq(statistic, df = df) (or p.value = pchisq(statistic, df = df, lower.tail = FALSE) ).

Altogether I would personally be slightly inclined to say it is better not to provide a df argument - I would think that the possibility of misuse is to high.


On Nov 8, 2006, at 7:40 AM, McGehee, Robert wrote:

> Is Sahotra's abuse sending a wishlist item to R-bugs, or is his error
> phrasing a suggestion in the form of a question? It seems others have
> commented on the inability to specify df for chisq.test (see:
>, and
> adding an
> option certainly seems like a reasonable suggestion to me.
> And of course, R-FAQ 9.2 does explicitly give a standard for reporting
> wishlist or non-bug items to the R-bugs:
> "There is a section of the bug repository for suggestions for
> enhancements for R labelled `wishlist'. Suggestions can be
> submitted in
> the same ways as bugs, but please ensure that the subject line makes
> clear that this is for the wishlist and not a bug report, for
> example by
> starting with `Wishlist:'."
> So if your qualm is with how onerous and manual the R bugs tracking
> system is, rather than if the sender sent his question/comment to the
> wrong list or in the wrong form, then perhaps an upgrade to the R bug
> tracker is in order rather than discouraging sending wishlist items to
> the bugs archiving system.
> Robert
> -----Original Message-----
> From:
> [] On Behalf Of Kasper Daniel
> Hansen
> Sent: Tuesday, November 07, 2006 10:24 PM
> To:
> Cc: R-devel
> Subject: Re: [Rd] Chi-squared test (PR#9350)
> (not cc'ed to R-bugs)
> If this is not a bug why do you abuse the bug report system to ask a
> simple question? Now a member of R-core has to use valuable time to
> handle this bug report, time that could be far more profitable spent
> making improvements to R (or spend it otherwise). This is incredible
> selfish behavior.
> Kasper
> On Nov 7, 2006, at 5:41 PM, wrote:
>> Full_Name: Sahotra Sarkar
>> Version: 2.2.0
>> OS: Windows XP
>> Submission from: (NULL) (
>> This is not a bug: I'm just wondering why chisq.test does not allow
>> the
>> specification of the degree of freedom (df).
>> ______________________________________________
>> mailing list
> ______________________________________________
> mailing list
> mailing list Received on Fri Nov 10 01:45:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 09 Nov 2006 - 16:30:40 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.