I am using the imhof and the farebrother methods intensively for 
computing the p-value of a certain statistical test. Thus I detected 
that, in some cases, both methods have some difficulties when the 
quantiles are extreme:

- imhof sometimes gives negative values. For example:
     > imhof(1.729879e+01,0.5)
     $Qq
     [1] -0.01641256

     $abserr
     [1] 0.0004728838

- farebrother gives the value 3 if the quantile is zero. (Since the 
distribution of the underlying test statistic is asymptotically given by 
those of a quadratic form, the value zero indeed occurs.)
     > farebrother(0,0.5)
     $lambda
     [1] 0.5

     $h
     [1] 1

     $delta
     [1] 0

     $r
     [1] 1

     $q
     [1] 0

     $mode
     [1] 1

     $maxit
     [1] 100000

     $eps
     [1] 1e-10

     $dnsty
     [1] 0

     $ifault
     [1] 2

     $res
     [1] 3

Do you have an idea what the reason could be?

Best regards,
Stefan Aulbach
Email: stefan.aulbach@uni-wuerzburg.de
http://www.statistik-mathematik.uni-wuerzburg.de/en/mitarbeiter/stefan_aulbach/

##################################################################################


Dear  Dr Pierre Lafaye de Micheaux,

I am postdoc at the Netherlands Cancer Institute and currently work on non-nested hypotheses testing. In a recent work (http://arxiv.org/abs/1210.4584v2) the test-statistic which I propose is asymptotically distributed as a weighted-sum-of-chi-squares. There are  no non-centrality parameters involved, however the weights can be negative. I use this test in a multiple testing scenario and therefore I need an approximation which is accurate also for very small p-values.

I have recently read your very interesting paper on a comparison of several methods and have a question concerning your R package CompQuadForm:

Which function can you recommend me to use for my problem (computing accurate, small p-values based on weighted-sum-of-chi-squares with pos. and neg. weights)? If I understand correctly the farebrother approach requires positive weights. I tried davies and imhof. I have the impression that I can obtain smaller p-values (e.g. of the order 10^-10) with imhof, whereas  davies gives me a value of zero.

I am very thankful for any kind of thoughts or help !

Best wishes from Amsterdam,

Nicolas
"n.stadler" <staedler.n@gmail.com>

##################################################################################

Dear P. Lafaye de Micheaux,

I am using your R package CompQuadForm to calculate p-values. But the p-values could be too small, e.g., less than 10^{-8}. Is it possible to get the too small p-value with accuracy less than 10^{-9}?

I tried an example using three methods and got different results as follows:
Q=200
> davies(Q,c(6,3,1))$Qq
[1] 0
> farebrother(Q,c(6,3,1),eps=10^{-13})$res
[1] 1.224786e-08
> imhof(Q,c(6,3,1),epsabs=10^(-13))$Qq
[1] -1.092451e-07
So which method gives a correct value? And why is imhof's p-value negative?

Thank you.

Best regards,
ChangJiang


In Mathematica, I obtain a positive value:
0.5+NIntegrate[Sin[(ArcTan[6*u]+ArcTan[3*u]+ArcTan[u]-200*u)/2]/(u*(1+36*u^2)^(1/4)*(1+9*u^2)^(1/4)*(1+u^2)^(1/4)),{u,0,+Infinity}]/Pi

The problem comes from numerical precision. I should consider using a multiple-precision library (see www.mpfr.org or www.boost.org/doc/libs/1_60_0/libs/multiprecision) in my C code.

Voir aussi:
https://cran.r-project.org/web/packages/Rmpfr/vignettes/Rmpfr-pkg.pdf

####################################################################################


My name is Zhonghua Liu, a student in biostatistics from Harvard. I am using your CompQuadForm R package to compute p values which might require high accuracy. 

I tried the following R code and obtain the following:

> davies(200,c(1,2,3),lim=900000,acc =0.0000000000001)
$trace
[1] 0.000000e+00 0.000000e+00 0.000000e+00 3.141588e-02 8.425265e+04 5.436841e-05 5.600000e+01

$ifault
[1] 1

$Qq
[1] 2


The Qq should be within [0,1], would you let me know how to fix this? Thanks a lot!

"Zhonghua Liu" <zhl618@mail.harvard.edu>

####################################################################

Dear Professor Lafaye de Micheaux,

for some educational reasons I am currently trying to re-compute Durbin and Watsons (1951, II) critical values of the lower and upper bounds of their Test-Statistic dL and dH  (and also table extensions like the one of Savin and White (1977)) (I know that this has no practical relevance as we can compute exact p-values, but as mentioned, this is just for educational purposes). The only promising source I found on the web was your R-package CompQuadForm and a 2002 Handbook Publication "Computing the Distribution of a quadratic form in normal variables" by Professor Farebrother. However, I am stuck in section 4 in which he writes, that one can determine the bounds "by setting g=1 and solving the equation 

Pr[ sum( (lambda - c) * z ²) ] = alpha         (4.1)

for c". My problem is that I can evaluate the left-hand side of (4.1) using pan/gadsol but I do not know how to solve (4.1) for c. The only (and maybe naive) ideas that I have are (i) to reverse the pan/gradsol algorithm such that it returns quantiles (which seems to be a quite tedious task) or to do a binary search over function values of pan/gradsol function (which is computationally inefficient). How exactly are the quantile-tables of dL and dH generated?
The other problem I have is to implement CompQuadForm-functions or the original Imhof/Koerts/Abrahamse algorithm "fquad" for the above purpose as it seems not to evaluate the same quadratic form as pan/gradsol does. How do I have to use/modify this algorithm such that it is fully compatible with pan/gradsol?

I know that these questions my be trivial to you and I feel really sorry to bother you with that but I see no other solution than to contact you directly. You would do me a great favour if you could give me some short help.

Thank you very much in advance.
Sincerely, Yours

Sönke Hoffmann, Germany

-----------
Dr. rer. pol. Sönke Hoffmann
Otto-von-Guericke University
Faculty of Economics and Management
Chair of Economic Policy (VWL III)
"Hoffmann, Soenke" <soenke.hoffmann@ovgu.de>
