From gerard at mail.generacio.com  Wed Dec  3 19:15:09 2008
From: gerard at mail.generacio.com (gerard at mail.generacio.com)
Date: Wed,  3 Dec 2008 19:15:09 +0100 (CET)
Subject: [Rd] function qt can fails if ndf < 1 (PR#13364)
Message-ID: <20081203181509.C42AD282C765@mail.pubhealth.ku.dk>

Full_Name: Gerard Torrent
Version: R version 2.8.0 (2008-10-20)
OS: Linux 2.6.27.5-41.fc9.x86_64 #1 SMP
Submission from: (NULL) (85.52.227.233)


In some cases qt complains about NaNs and don't gives the correct result:

> qt(0.1,, 0.1)
[1] NaN
Warning message:
In qt(p, df, lower.tail, log.p) : NaNs produced

But the result can be found:
> pt(-1.60443e+06, 0.1)
[1] 0.09999997

If I replace the current method by bisection method in file file src/nmath/qt.c
the result is computed fine.

int cont=0;
do {
	cont++;
	nx = lx + (ux - lx)/2.0;
	if ((pp = pt(nx, ndf, TRUE, FALSE)) > p) {
		ux = nx; pu = pp;
	} else {
		lx = nx; pl = pp;
	}
}
while ((ux - lx) / fabs(nx) > accu && cont < 100);




[Rd] function qt can fails if ndf < 1 (PR#13364)
gerard at mail.generacio.com