Function PRBF

This is a function to find the associated probability of a value (FR) of an

F Ratio

With DA representing Degrees of Freedom Above

And DB representing Degrees of Freedom Below

It returns -999 if any input parameter is less than or equal to zero.

It can also be used to evaluate

Chi-Squared

With DA representing the degrees of freedom

DB set to as large number as possible (999 is probably sufficient)

FR set to the chi-squared value divided by the degrees of freedom DA

Student’s “t”

With DA set to unity (1)

DB set to the degrees of freedom

Fr set to the value of t squared

A normal variate

With DA set to Unity

DB set to as large a number as possible

FR set to the square of the normal variate

(The function GAUS, which is called by PRBF, gives this probability directly.)

It is based on

Jaspen, N., “The calculation of Probabilities corresponding to Values of Z, t, F, and Chi-squared” Education and Psychological Measurement, 1965 Vol 25, pp 887-880

This function is written in ASA FORTRAN IV – but it should be fairly easy to translate into a more modern language.

Enjoy

FUNCTION PRBF(DA,DB,FR)

C PRBF (SEE 11.8) STATISTICAL FINDS PROBABILITY OF F-RATIO

C DA = DF ABOVE,DB=DF BELOW,FR=F RATIO – PRBF=-999 =OUT OF RANGE

PRBF = -999.

IF(DA.LE.0.0.OR.DB.LE.0.0.OR.FR.LT.0.0) RETURN

PRBF = 1.

IF(FR.EQ.0.) RETURN

LI = 500

IF(DA.EQ.1.0.AND.DB.GT.LI) X = SQRT(FR)

IF(DA.EQ.1.0.AND.DB.GT.LI) GO TO 15

FT = 0.

PRBF = 0.

X = DB/(DB + DA*FR)

NA = DA + 0.5

NB = DB + 0.5

VP = NA + NB – 2

FA = NA

FB = NB

IF(NA.EQ.NA/2*2.AND.NA.LT.LI) GO TO 1

IF(NB.EQ.NB/2*2.AND.NB.LT.LI) GO TO 4

IF(NA+NB.LT.LI) GO TO 6

GO TO 14

C FA EVEN AND LESS THAN LI (THE LIMIT FOR ITERATION)

1 XX = 1.-X

2 FA = FA – 2.

IF(FA.LT.1.) GO TO 3

VP = VP – 2.

FT = XX*VP/FA*(FT+1.)

GO TO 2

3 FT = X**(.5*FB)*(FT+1.)

IF(FT.GT.0.)PRBF = FT

RETURN

C FB EVEN AND LESS THAN LI (THE LIMIT FOR ITERATION)

4 FB = FB – 2.

IF(FB.LT.1.) GO TO 5

VP = VP – 2.

FT = X*VP/FB*(FT+1.)

GO TO 4

5 FT = 1. – (1.-X)**(0.5*FA)*(FT+1.)

IF(FT.GT.0.)PRBF = FT

RETURN

C FA AND FB ODD – FA+FB LESS THAN LIMIT FOR ITERATION

6 TH = ATAN(SQRT(FA*FR/FB))

ST = SIN(TH)

CT = COS(TH)

C2 = CT*CT

S2 = ST*ST

A = 0

B = 0

IF(DB.LE.1.) GO TO 9

7 FB = FB – 2.

IF(FB.LT.2.) GO TO 8

A = C2*(FB-1.)/FB*(1.+A)

GO TO 7

8 A = ST*CT*(1.+A)

9 A = TH + A

IF (DA.LE.1.) GO TO 13

10 FA = FA – 2.

IF (FA.LT.2.) GO TO 11

VP = VP – 2.

B = S2*VP/FA*(1.+B)

GO TO 10

11 GF = 1.

K = DB*0.5

DO 12 I = 1,K

X1 = I

12 GF = X1*GF/(X1-0.5)

B = GF*ST*CT**DB*(1.+B)

13 FT = 1. + 0.636619772368*(B-A)

IF(FT.GT.0.)PRBF = FT

RETURN

C FA AND/OR FB EXCEED LIMITS

14 FA = 2./9./FA

FB = 2./9./FB

CR =FR**0.333333333333

X = (1.-FA +(FB-1.)*CR )/SQRT(FB*CR*CR + FA)

15 FT = GAUS(X)

IF(FT.GT.0.) PRBF = FT

RETURN

END