From maechler at stat.math.ethz.ch  Tue May 13 19:22:10 2003
From: maechler at stat.math.ethz.ch (maechler@stat.math.ethz.ch)
Date: Tue May 13 18:22:23 2003
Subject: [Rd] qt(p,df) discontinuous in p for df in 1.01->1.7 (PR#2991)
Message-ID: <200305131622.h4DGMA2b001013@pubhealth.ku.dk>

>>>>> "jens" == jens lund <jens.lund@nordea.com>
>>>>>     on Tue, 13 May 2003 13:29:15 +0200 (MET DST) writes:

    jens> Full_Name: Jens Lund Version: Version 1.7.0
    jens> (2003-04-16) OS: Win NT 4.0 SP 6 Submission from:
    jens> (NULL) (193.3.225.210)



    jens> As the T distribution is symmetrical around 0
    jens> qt(0.5,df) should return 0 for any df.

    jens> However for df close to 1 it seems to have problems as
    jens> seen by: qt(0.5,seq(1,1.1,by=0.0001))

    jens> For example:
    >> qt(0.5,1.01)
    jens> [1] -0.2300470

    jens> Higher df as df=1.1 (and up to approx df=1.7) seem to
    jens> have problems as it also gives discontinuities (the
    jens> plural form!):
    jens> plot(seq(0.1,0.9,by=0.001),qt(seq(0.1,0.9,by=0.001),1.1),pch=".")

    jens> When df is close to 1 it appears as one discontinuity
    jens> at p=0.5, and as df increases there are two
    jens> discountinuities symmetrical around 0.5 and moving
    jens> away from 0.5.

    jens> Keep up your outstanding work on R ;-)

thanks!

Bug confirmed.  qt() uses an algorithm based on

  *  Reference:
  *  Algorithm 396: Student's t-quantiles by G.W. Hill
  *  Comm. A.C.M., vol.13(10), 619-620, October 1970

and the basic C code in R has been in place for about 6 years
now, and it does work piecewisely on the range of "p" (depending
on df). --> look at <Rsrc>/nmath/qt.c  if you're interested.

As a first guess:
   It may be that G.W.Hill  did not think of using df between
   1 and 2 (only thought of integer df).

I need to get my hands on that paper.

Thanks a lot for reporting the bug so clearly!]

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><


[Rd] qt(p,df) discontinuous in p for df in 1.01->1.7 (PR#2991)
maechler@stat.math.ethz.ch