[Gretl-users] pvalues [was menu restructuring]

Allin Cottrell cottrell at wfu.edu
Thu Jul 13 12:49:56 EDT 2006


On Wed, 12 Jul 2006, Talha Yalta wrote:

> 3- Finally, I would like to submit my testing of the p-value 
> finder in gretl in terms of numerical accuracy. Looks like 
> gretl has some problems with calculating the correct values 
> for the left tails for several distributions. Some may find 
> the inaccuracies insignificant. Still, it might be worth to 
> take a look into it. The results are attached as a ods 
> spreadsheet.

Thanks for your rigorous testing.

I have now fixed the code for p-values against the t 
distribution: the gretl results agree exactly with ELV.

As for the Chi-square and F results, there's a basic problem 
here, to do with finite-precision computer arithmetic.  In 
principle, if you calculate

P1 = Prob(X <= X0) and
P2 = Prob(X >= X0)

then you should have P1 = 1 - P2.  But that's not the case with 
double-precision numbers, or not for all values of X0.

For instance, you had some cases with very small X0.  The 
"p-value" quoted by gretl is P2, and in many cases it equals 
"1.0". However, if you use the underlying cephes engine to 
calculate P1, you get a (very small) positive answer that agrees 
precisely with ELV.  (But if you then try finding 1 - P1 you get 
1.0 again!)

The trouble is that doubles do not model the real line, and the 
set of representable doubles is denser close to zero than it is 
just short of 1.  That is, there are numbers D such that D
does not equal 0.0 but 1 - D = 1.

I've fixed this, to an extent, for the "pvalue" command.  You'll 
now see this sort of thing:

? pvalue X 50 0.999
  Chi-square(50): area to the right of 0.999 = 1
  (to the left: 1.15939e-33)

I'm not sure how to handle it for the pvalue() function in genr 
-- maybe there could be some option to return the left-tail 
value rather than the right.  Perhaps if you enter a negative x 
you get the left value?

Allin.




More information about the Gretl-users mailing list