Helms, R.W. and DeLong, E.; (1975). "Al angorithm for the approximate null distribution of Hotelling's generalized Tos-squared."

BIOMATHEMATICS TRAINING PROGRAM
AN ALGORITHM FOR THE
APPROXIMATE NUll DISTRIBUTION
OF HOTEllING'S GENERALIZED T0 2
by
Ronald W. Helms
and
Elizabeth Delong
Department of Biostatistics
University of North Carolina
Chapel Hill, NC
27514
Institute of Statistics Mimeo Series No.
July, 1975
970
Keywords:
2
To' Trace Criterion, Multivariate Analysis
LANGUAGE
ANSI Fortran
Summary
An algorithm is presented for computing an approximation
to the cumulative distribution function of Hotelling's
generalized
T~
statistic.
2
DESCRIPTION AND PURPOSE
Hotelling's Generalized To2 statistic is defined as
where Hand E are independent p x p matrices;
H _ W (nl, E ,
p
~),
and is positive semidefinite;
E - Wp (n2, E , 0), and is positive definite;
and where W (n, E,
p
~)
--
denotes the Wishart distribution for p x p matrices,
with n degrees of freedom, covariance parameter matrix E, and noncentrality
parameter matrix
The purpose of the algorithm is to compute an approximation
to the cumulative distribution function of the
~-....
=0
cen~raZ
distribution (i.e.,
of T2 •
o·
COF = Pr
[T~ ~
T
I
~
= 0].
(1)
The central distribution is also called the "nu ll" distribution, in part
because
is Itnulllt and in part because this distribution is usually the
relevant one under the Itnull hypothesis lt of certain multivariate tests.
~
3
METHOD
This algorithm evaluates the cumulative distribution fuction of the
distribution of Hotelling1s T~ for certain special cases; for combinations
of the parameters which do not satisfy the special cases the algorthim
evaluates the cdf of a distribution which approximates the T~ distribution.
The following notation will be helpful; let
where Hand E are as described above and
s = min
{n1~
p}
is the number of non-zero eigenvalues of H E- 1.
leads to difficulties which can be bypassed:
The case s
= n1
<
p
the distribution of U(s) can
be derived from the distribution of U(p) [p < n1] by mapping
(2)
Thus only the case nl
~
P need be considered.
handles this mapping in the case nl < p.
The algorithm automatically
4
Special cases.
The algorithm produces exact results {to the accuracy
of the incomplete beta function algorithm} in the following special cases.
z
In the case p = 1 the To is proportional to an F-statistic:
z
To /n l
'V
F (nl, nz)'
hence,
and the algorithm evaluates:
where
w = T/{T+n 2} = U/{U+l}
U = T/n 2 .
In his original paper Hotelling {1951} derived the exact distribution
of T2 for the special case p = 2:
o
{n 2-1)/2
2 < T] = I {n -l,n }+;rr _f[_{_nl_+_n2_-1_}_/2_]_ ( 1 - W)
Pr[T 0
w 1
2
f{n /2} f{n /2}
1+w
l
2
I
2
w
l
(n l - ,n 2+1)
2
2
where
w = T /{2n 2+T } = U/{U+2}.
This result is used by the algorithm when p=2.
It is interesting that
Johnson and Kotz (1972, page 199, equation (41}) give an incorrect version of
this
result.
5
Note that because of the mapping (2) one of these special cases
will be invoked if
nl = 1 or nl = 2 and n < p. Rao(1965, Section
l
8b(xii)) treats the special case nl = separately and shows that the
cdf of the T~ distribution is equivalent to the incomplete beta function,
but because of the mapping (2) no special coding is needed for this case.
Moment-Based Approximations.
Pillai and Young(1971) developed
the technique of approximating the density of U(p) by a density similar
to the density
of a central F distribution.
The approximation is based
upon finding the parameters of the F-type distribution which make the
first three moments of the distribution of U(p) equal to the first three
moments of the F-type distribution.
The first three central moments of
the central distribution of U(p) are given by Pillai(1960), Pillai and
Samson(1959), and again in Pillai and Young(1971) as:
~l =
P (2m + p + 1) / (2n)
~2
= [p (2m + p + 1) (2m + 2n + p + 1) (2n + p)]/ [4n 2 (n - 1) (2n + 1)]
~3
= p (2m + n + p + 1) (2m + p + 1) (2m + 2n + p + 1) (n + p) (2n +p)
2n 3 (n - 1) (n - 2) (n +1) (2n + 1)
where
m = (nl - P - 1) / 2
n
= (n2
- P - 1) / 2.
The F-type density function
a l
f( x; a" b K) = xa/{QI-' (+1
a , b-a-1) K + (l+x/K)b}
has the following first three central moments
O<x<oo
6
~Fl
= K (a+l) / (b-a-2)
~F2 =
2
[K (a+l) (b-l)] / [(b-a-2)
2
(b-a-3)]
~F3 = [2 K3 (a+l) (b-l) (a+b)] / (b-a-2)3 (b-a-3) (b-a-4)].
This F-type distribution is identical to the standard central F distribution
with
k1 and k2 degrees of freedom if one imposes the restriction
and uses the relations
However, without the restriction on K the F-type distribution has three
parameters: a,b, and K.
Setting the first three moments of the distribution of U(p) and
the F-type distribution equal and solving for a,b, and Kyields
7
3
a
=
Z
(2UIUZ + 3UIU3
Z
Z
6UIUZ
UZU3) / (UZU3 + 4UIUZ
Z
Z
UIU3)
2
b = [ (a+l) (a+3) - Ul / Uz] / [ (a+l) - Ul / Uz]
K = Ul (b-a-2) / (a+l)
Note that in Pillai and Young (1971) there is a typographical error in
the expression for a; the last minus (-) sign in the expression above is
erroneously given as a plus (+) sign in that paper.
The first three moments of these distributions do not exist for
all possible values of the parameters.
The following is a summary of
necessary and sufficient conditions for the existence of the indicated
moments:
Distribution
U(p)
Moment
Conditi on for existence
F-Type
Moment
Condition for existence
Ul
n2 > p+l
UFl
b-a > 2
U2
n2 > p+3
UF2
b-a > 3
u3
n2 > p+5
UF3
b-a > 4
In each of these cases it is assumed the mapping (2) has been performed if
nl < p and the statements and expressions apply to the transformed parameters.
8
If the combination of parameters is such that one of the third-order moments
(~3
or
~F3)
does not exist, one can obtain a two-moment approximation by
equating the first two moments of the two distributions.
The following
expressions for a, b, and K will generate a two-moment approximation:
K
=p
a = [~2
b
=
[
~l
~l - p) +
2
~l ( ~l + P)]/(P~2)
2
( ~l + p) + ~1~2 + 2p~2]/(P~2)
Similarly, a one-moment approximation is generated by the following expressions:
K = p
a
=
p (2 m+ p + 1) /2 - 1
b = P(2 m+ 2 n + p + 1) /2 + 1.
Operational procedure.
The algorithm first checks the input
parameter values to determine whether they have proper values (e.g.,
T ~ 0, etc.).
The algorithm then checks for the special case nl < p;
if so, the mapping (2) is performed. The upper limit, T, is converted
to a U(p):
cases p
=
evaluated.
U = T/n .
2
1 or p = 2.
The algorithm next checks for one of the special
If a special case applies, the exact cdf is
If neither of the special cases apply, the algorithm computes
m and n (defined above) and determines whether the third moments of both
distributions exist.
approximation is used.
If both third moments exist the
three-moment
Otherwise a two-moment approximation is attempted.
If one of the second-order moments does not exist, a one-moment approximation
9
is attempted.
If one of the first-order moments does not exist the
algorithm sets the failure indicator (IFAULT) and returns control to the
calling program.
If the three-, two-, or one-moment approximation is
used, the algorithm uses the incomplete beta function subprogram to
evaluate:
CDF
=
I (a+l, b-a-l)
w
- Pre T~ < T ]
where
w = T/(T+Kn 2 )
and where
= U/(U + K)
a, b, and K are evaluated from the expressions of the
highest-moment approximation applicable.
10
STRUCTURE
SUBROUTINE HOTELL (T, N1, N2, IP, COF, IFAULT, IAPRX)
Formal Parameters:
~ Pr[T~ ~
T
Real
input:
The algorithm computes COF
N1
Integer
input:
Number of degrees of freedom of1the distribution of H in T~ =n2Tr(~ ~- )
N2
Integer
input:
Number of degrees of freedom of the distribution of E.
IP
Integer
input:
The matrices Hand E are IP x IP; IP
corresponds to the ~parameter p in the
discussion.
COF
Real
output:
COF
I FAULT
Integer
output:
Failure indicator.
IAPRX
Integer
output:
Indicates the type of approximation used.
~ Pr[T~ ~
T]
T].
IAPRX=-3 :
Exact computation for
T=O
IAPRX=-2:
Exact computation for
special case p=2
IAPRX=-l:
Exact computation for
special case p=l
IAPRX=O:
Algorithm failure;
approximation technique
not applicable
IAPRX=l:
One-moment approximation used
IAPRX=2:
Two-moment approxmiation used
IAPRX=3:
Three-moment approximation used
11
Failure Indicators:
IFAULT
=0
indicates no errors were detected.
IFAULT
= -1
indicates one of the input parameters has an
improper value [i .e., T<O, Nl < 1, N2 < 1,
IP < lJ. COF is returned with a value of -lE75.
IFAULT
=
indicates the combination of parameters T,
Nl, N2, and IP is such that the first moment
of the approximating distribution is not finite,
i.e., the technique is not applicable. COF is
returned with a value of -lE75 and IAPRX = O.
IFAULT
=2
indicates W~O or W~ 1 where W= T/(T + K * N2),
which should never happen, i.e., IFAULT = 2
indicates a programming error. COF is returned
with a value of -lE75.
12
RESTRICTIONS
The parameters
n , n2 , and p must satisfy the restrictions
l
given above for the existence of moments for a particular approximation
to apply; i.e., the minimal restriction is
n > p+l, which applies
2
to both the original parameters and the transformed parameters if the
mapping (2) is invoked.
The restrictions shown for
a and
b must
also be satisfied, but there is no simple statement of these restrictions
in terms of nl , n2 , and p.
These restrictions guarantee that the
algorithm will operate as described but do not guarantee that the
approximation used will be accurate.
Additional restrictions are
described in the section discussing accuracy.
13
AUXILLARY ALGORITHMS
The present version of HOTELL uses BETAIN, Algorithm AS 63,
liThe Incomplete Beta Integral ," by Majumder and Bhattacharjee
(1973).
BETAIN requires the prior computation of the complete beta function,
B(p,q)
= r(p)r(q)/r(p+q). HOTELL assumes the availability of a single
precision function subprogram, ALGAMA (X), which evaluates loge r(x).
Virtually all computer manufacturers provide an efficient, accurate
subprogram for log r(x) and such a routine may be easily substituted
for ALGAMA in HOTELL.
If such a routine is not available the algorithm
of Pike and Hill (1960) may be implemented in Fortran under the name
ALGAMA.
14
ACCURACY
Errors in this approximation have three components:
(a)
differences
between the cdf's of the F-type distribution and the distribution of u(p),
(b)
errors in approximating the incomplete beta function, and (c) calculations
performed in the routine.
Pillai and Young (1971) included a comparison of the approximations to
the exact distribution for n
80, and 100, and for
(p,m)
=
(n 2-p-l)/2
=
5, 10, 15, 20, 30, 40, 50,60,
(p, (n l -p-l)/2 ) = (3,0), (3,3), (4,0), and (4,2).
They concluded that this approximation "... provides about three significant
=
digits accuracy in the percentage points for n ~ 10.
In some cases
n
>
5
is sufficient for this accuracy" and that "... the distribution function for
[this approximation] provides a good approximation [about three decimal places]
to the exact distribution of U(p) for n ~ 10 and for the whole range of U(P)."
Note that the first quote refers to the percentage points, i.e., the inverse
of the cdf, and the second quote refers to the cdf itself.
(Emphasis added.)
In our tests of this routine we reproduced the relevant results of
Table II in Pillai and Young (1971) to the number of digits given there.
Errors of types (b) and (c) above are more within the control of the
If HOTELL is implemented on an IBM 360, 370, or other
user of the algorithm.
computer with a short
(~
24 bits) single precision floating point mantissa,
double precision is absolutely essential for accurate computation, especially
for the special case
p
= 2. A double precision version is easily produced; one
need change only the initial declarations, including the declaration of the
arithmetic statement function CBF (complete beta function), the names of the
functions EXP, ALGAMA, and ALOG in statement 9,
and function BETAIN.
In a
double precision version of HOTELL (and BETAIN), or a single precision version
on machines with long floating point mantissas, the computational errors in
~
15
BETAIN and HOTELL will typically be negligible compared to the error of the
approximating technique (type (a), above).
16
REFERENCES
Hotelling, H. (1951)
A Generalized T-test and Measure of Multivariate
Dispersion, Proceedings of the 2nd Berkeley Symposium on Mathematical
Statistics and Probability, 23-41.
Johnson, N. L. and S. Kotz (1972).
Distributions in Statistics:
Continuous Multivariate Distributions.
John Wiley & Sons, Inc.,
New York, 1972.
Majumder, K. L. and G. P. Bhattacharjee (1973).
Incomplete Beta Integral.
Pike, M.C. and I. D. Hill (1966).
Function.
Algorithm AS63.
The
Applied Statistics, 22, 409-411.
Algorithm 291.
Logarithm of the Gamma
Commun. Ass. Comput.Mach., 9, 684.
Pillai, K.C.S. (1960).
Hypotheses.
Statistical Tables for Tests of Multivariate
The Statistical Center, University of the Philippines,
Manila.
Pi11ai, K.C.S. and P. Samson, Jr. (1959).
of T2 •
On Hote11ing's Generalization
Biometrika, 46, 160-165.
Pil1ai, K.C.S. and D. L. Young (1971).
Hotel1ing ' s Generalized
T~.
On the Exact Distribution of
Journal of Multivariate Analysis,
1,90-107.
Rao, C. R. (1965).
Linear Statistical Inference and Its Applications.
John Wiley & Sons, Inc., New York, 1965.
1 8
SUB ROUT I NE HOT ELL LIS TIN G
HOTL
o
HO'l'L 10
HOTL 20
SUBFOUTINf HOTELL(T,'l1,N2,IP,CDF,IFAULT,IAPRX)
BOTL 10
HOTL 40
HOTL 50
DESCRIPTION AND PURPOSE
HOTL 60
HOTL 70
!l0'!'ELL!NG'S GENERALIZED T(0)**2 STATISTIC TS DEFINFD AS
HOT L 80
IIOTL 90
T«))**2 = N2*TPACE(H*f**-1)
flOTL 100
HOTL 110
WHERE HAND E ARE INDEPENDENT P X P MATRICES;
HOTL 120
H flAS A w(P;N1,S,D) DISTRII3UTICN A1'lD IS POSITIVE SEMIDEI'INITE; HO':'L ne
Han 140
HOTL 150
F HAS A W(P;N2,s,0) DISTRIBUTION AND IS POSITIVE DEFINITE;
HOTL 160
HOTL no
AND WH";"! W (P;N,S,D) D"':NClTES THE WISHAFT DISTRIBUTION FOP P X f'
MATRICES, WITH N DEGREES OF FREEDC~, COVAFIANCE PARAMETER MATFIX [1OTL 180
S, AND NONCENTRALITY PARAMETER MATRIX D. THIS ALGORITHr>l COMPUTES BOTL 190
HOTL 200
A~ APPROXIMATION OP THE CUMULATIVE DISTRIP~mION
FUNCTION np THE
CEN!RAL DISTIHDUTION (I. E., D=O) OF T (0) **2; iHAT IS, THIS
HOTL 210
ALGORITHM COMPUTES AN APPROXIMATION TO
HOTL 220
!lOTL 230
Hon 240
C!)F = PR (1' (0) **2 < T I 0=0)
HOTL 250
THf CENTRAL DISTRIBUTION IS ALSO CALLED TH~ "'lULL" DISTRIBUTION,
HOTL 260
IN PART BrCAUSE D IS "NULL" AND IN PART BECAUSE THIS DISTRIBUTION HOTL 270
IS USUALLY THE REL~VANT ON~ UNDER THE "NULL HYPOTHFSIS" OF CERTAINHOTL 280
MULTI VARI AT E TI'S1'S.
HO'!'L 290
HOTL ~OO
HOTL 310
METHOD
HOTL 320
HOTL 330
THE ALGORImilM PRODUCES EXACT BESULTS (TO THE ACCUf<ACY OF THE
BOTL 340
I:<CO"lPLETE ilETA FUNCTION ALGORITHM) IN 'rHE SPFCIAL CASES IP=1,
Han 350
I P= 2, AND T =0 •
flOTL 360
HOTL 370
IF NJN~ OF mHE SPECIAL CASES APPLY, THEN THE ALGO?ITHM
HOTL 380
IS AN IMPLE~ENTATION OF AN APP90XIMATION DEVELOPED BY PILLA I
HOTL 390
AND YOUNG (1971). THI' APPROXIl'lAT:::ON IS BASED UPON SELECTING AN
HOTL 400
E-TYPE DISTRIBUTION WHICH HAS THE SAME FIRST THREE MOMENTS AS
HOTL 410
THF DISTRIBUTION OF
fiOTL 420
HOTL 430
U = (T(0)**2)/N2
HOTL 440
fiOTL 450
THEN
PR (T (0) **2 < T)
IS APPROXIMATED BY
PR(F < T/N2).
AFTERHOTL 460
A TFANSFORMATION,
PR(F < T/M2)
IS EVALUATED AS
BOT L 470
PF(BETA < W = T/(Tf-K*N'2)) = INCOMPLETE BFTA FUNCTION EVALUATED AT HOTL 480
~, WHERE
BETA
HAS THE APPROPRIATE BETA DISTFIBUTION.
HOTL 490
HOTL 500
IF THE THIFD MOMENT OF THE F-TYPE DISTRIBUTION DOES NOT EXIST,
HOTL 510
BUT THE SECOND MOMENT DOES EXIST, THE APPROXIMATION IS BASFD ON
HOTL 520
THE FIRST TWO MOMENTS.
LIKEiHS E, IF BOTH THE THUD AND SECOND
HOTL 530
MOMENTS DO NOT EXIST, BUT THE FIPST MO~ENT DOES EXIST, THE
HOTL 540
APPROXIMATION IS BASED ON THE PIPST MOMENT.
IF NONE OF THE
HOTL 550
THRE! MO~!NTS EXISTS, THE APPROXI~ATION IS NOT APPLICABLE AND
HOTL 560
THE ALGORITHM DOES Nor A~TEMPT AN APPROXI~ATION.
HOTL 570
HOTL 580
HOTL 590
USAGE
HOTL 600
C***
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
c
c
C
C
:::
C
C
C
c
c
c
C
C
C
c
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
r
fH"l'l'T.
fi1()
19
SUB R0 UTI NE HOT ELL LIS TIN G
c
c
c
c
C
C
C
C
C
C
...,..
C
C
C
c
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
c
c
c
C
c
c
C
c
C
C
C
C
C
C
c
C
C
C
C
C
C
C
C
C
c
C
("
HOT L 620
HOTL 630
HOTL 640
HOTL 650
D~SCPIPTION Of PARAMETERS
HOTL 660
HOTL 670
IIOTL 680
T
-HEAL !NPUT: THE ALGORITHM COMPUTES
HOTL 691'
cnr = PR(T(0)**2 < T) APPROXIMATELY
!I0TL 700
HOTL 710
N1
-INTEr-ER I~PUT:
NUMBER OF D~GREES OF FREEDOM OF THE
DISTRIBUTION OF H IN T(0)**2=TR(H*E**-1) HOTL 720
HOTL 730
HOTL 740
N2
-INTEGER T.PU~:
NUMB~R OF DEGREES OF FREEDOM OF THE
HOTt 750
DISTRIBUTION OF E
HOT L 760
HOTL 770
IP
-INTEGF~ INPUT:
THE MATRICES HAND E ARE IF X IP; IP
HOTL 780
COFRESPONDS TO THE PARAMETER P IN THE
HOTL 790
DISCUSSION
HOTL 800
HOTL 810
C1F
-FEAL OUTPUT: CDF = PR (T(0)**2 < T)
APPliOXIMATELY
HOTL 820
IIOTL 830
HOTL 840
IFAULT -INTEGER FAILURE INDICATOR:
HOTL 850
HOTL 860
INDICATES NO ~RROFS WEPE DETECTED
lFAULT=O
HOTL 870
HOTL 880
INDICATES ONE OF THF INPUT PARAMETFRS
IFAOLT=-1
HI\S AN IMPPOPFll VALU~, (I, E. T<O, N1<1, HOTL 890
HOTL 900
N2<1, IP<1). CDF IS RETURNED WITH A
HOTt 910
VALU~ OF -11'.:75.
HOTL 920
INDICATES ~HE CO~RINATIO~ OF PARAMETERS HorL 930
IFAULT=1
Hart 940
T, N1, N2, AND IF IS SUCH TH7\T THE
HOTL 950
FIRST ~OI'lENT OF TH~ APPROXIMATING
HOTL 960
DISfRIBUTION IS Nl'T' FINITE, I.E., THE
HOTt 970
TECHNIQUE IS NOT APPLICA9LE. CDF IS
HOTL 980
RETURNED W!TH A VALUE OF -1!75 AND
HorL 990
IAPRX=').
HOTL1000
IIOTL1010
BDICATES W .LE. C OF W .GP. 1 WHFRE
I FA UL 1'=2
HOTL1020
W=T/(TtK*N2), WHICH SIIOULD NEVER
HOTL1030
HAPPEN, I.E., IF7\ULT=2 INDICATES A
HOTL1040
PIl OG R7i I'll'll NG EIl FO R.
CDF IS PET URNFD
HOTL1050
WI'rH 1\ VA UP" OF -1 E75.
HOTL1060
HOTL1070
HOTL1080
-IN~EGER INDICATOR OF TYPE OF APPROXIMATION USED
DPRX
HOTL1090
HOTL 1100
EXACT COMPUTATION FOR T=O
IAPRX=-3
HOTL111<'
HOTL1120
EXACT COMPUTATION FOR SPECI7\L CASE P=2
IA PF.X=-2
HOTL1130
HOTL1140
EXACT COMPUTATION FOR SPECIAL CASE P=1
IAPFX=-1
HOTL1150
HOTL1160
ALGORITHM FAILUFE; APPROXIMATION
IAPRX"'O
HOTL1170
TECHNIQUE NOT APPLICABLE
HOTL1180
HOTL1190
ONE-MOMENT APPROXIMATION USED
IAPRX=1
HOTL1200
HOTL 1210
TWO-MOMENT APPROXIMATION USED
I APRX=2
HOTL1220
HOTL1230
THFEE-MOMENT APPROXIMATION USED
IAPRX"'3
HOTL1240
HOTL1250
HOTL 1260
SUBFOUTINES P!QUIFED
H()'T'T.1 ?70
CALL IIOT£LL
(T,~1,N2,IP,CDl",IFA(JLT,IAPRX)
20
SUB R0 UTI NE HOT ELL LIS TIN G
C
C
C
C
C
C
C
c
c
c
C
c
C
C
C
c
c
C
C
C
C
c
C
C
C
C
C
C
C
c
::
C
C
C
C
C
C
C
c
C
C
HOTL1280
1I0TL1290
HOTL1300
HOTL1310
HOTL1]20
R"';FFPENCES
HOTL1 ]]0
HOTL1340
"IA.J{J"ID~R, K, L. ANO G. P. BHATTACH ARJFE (1973).
ALGORITHM AS63.
HOTL 1350
THE INCO"'PLETE BETA INrEGRAL.
APPLIED STArIS~ICS, 22,
HOTL1360
409-411.
HOTL1]70
HOTL1380
PILLAI, K.C.5. AND D.L. YOUNG (1971).
ON THE EXACT DISTRIBUTION
HOTL1390
OF HOT":LLING'S GENERALIZED T (0) **2.
JOURNAL OF
HOTL1400
MULTIVHIAT? ANALYSIS, 1, 90-107.
HOTL1410
HOTL1420
HOTL 14]0
HOTL1440
HOTL1450
SU9?U{JTI'<E HO":'ELL(1',N1,N2,IP,CDF,IFAULT,IAPRX)
HOTL1460
HOTL1470
TI!i::' ALGORI'!'H"I COf"PUTFS AN 71PPROXIMATION TO THE CUMULATIVE
HOTL1480
DISTRIBUTION FUNCTION OF THE CENTPAL DISTRIBUTION OF HOTELLING-S
HOTL1490
GENERALIZED
1'(0)**2
STATIS~IC, I.E.,
HOTL1500
HOl'L1510
CDF = PR (T(O) **2 .LT. 'II, APPROXIMATELY.
1I0TL1520
HOTL15]0
HOTL 1540
VERSION DATE
14 JULY 1975
HOTL1550
HOTL1560
SfJPROUTINE UOTELL(T,N1,N2,IP,CDF,IFAULT,IAPFXI
UOTL1570
HOTL 1580
DF.:CLA HTIONS
HOTL1590
HOTL1600
ARGUMENTS
HOTL1610
HOTL1620
PEAL
CDF,'!'
HOTL16]:)
INTEGER N1,N2,IP,IFAULT,IAPFX
HOTL1640
HOTL 1650
FUNCTION SUBPFCGRAMS
HOTL1660
HOTL1670
RFAL
BETAIN,CBF
1I01'L1680
C8F(A,B)= EXP(ALGAMA(A)tALGAMA(B)-lILGAMA(AtB»
HOTL1690
HOTL1700
INTERNAL VARIABLES
IIOTL1710
REAL
A,A1 ,A2,B,B1 ,B"ETA,TADD,r~MP1,T~RH1,TER"2,TK,TM,TMU1,TMU2 HOTL 1720
HOTL 1730
R~AL
TMU3,TMU1SQ,TMU2SQ,TN,TN1,TN2,TP,TWOTN,U,W
H01'L1740
HOTL1750
INTERNAL CONSTANTS
HOTL1760
HOTL1770
REAL
ZERO/OEO/,ONE/1EO/,T~1/2EO/,THFFE/3E0/,FOUR/4EO/,SIX/6
EO/
PFAL SQRTPI/1.77245]9/
HOTL17ao
HOTL1790
HOTL1800
BEGIN EXECUTION
HOTL1810
HOTL1820
IAPFX
0
IFAULT = -1
Hon 1830
CDF
-1E75
HOTL184(\
HOTL1850
HOTL1860
CHECK rOR T • LF. Z~RCl
OP INVALID VALUES OF N 1, N2, AND IP
HOTL1870
!F(N1 .LT. 1
.Oli.
N2 .LT. 1
.OR.
IP .LT. 1) GO TO 20
HOTL18'lO
! F (T) 20, ?, 3
1I0TL1890
2 CDF=ZEFO
HOTL 1900
IAPRX = - ]
HOTL1910
IHULT = 0
HOTL1920
(;0 '1'0 ?O
HO'l'T.1qlO
SF-TAIN
(APPLIED STATISTICS ALGORITHM 7156].
BELOW)
P~FEF";NCE
=
=
SEE FIRST
21
SUB R0 UTI NE HOT ELL LIS TIN G
c
c
c
("
HOT L 1940
Hon 1 950
1I0TL1960
HOTL1970
(~1.N2,IP) ~APS 1'0 (II.',N1PI2-P,N1)
H01'L1980
HOTL1990
3 IF (N1 • GE. H)
1,0 TO 4
lJO'fL2 000
Te.1
IP
HOT L201 ~
TN?
N1tN2-TP
HOTL2020
TP
N1
HOTL2030
GO TO ')
HOTL2040
4 "'''11
N1
HOTL2050
TN2 = N?
HOTL21'60
T!'
IP
HOTL2010
5
U
T/N?
HOTL2080
HOTL2090
CHFCK FOR SPECI~L CASE P
HOTL2100
HOTL2110
IF (TP. GT. ONE) 1,0 TO 6
HOTL2120
IAPPX
-1
I10TL2 1 30
A1=TN1/TWO
HOTL2140
B1='!'N2/'!W!)
HOTL2150
W=TI/ (11+0"11')
HOTL2160
GO cO 15
HOTL2110
HOTL21fH'
CHECK FOR SPECIAL CASE P=2
HOTL2190
HOTL221)0
6 IF (TP .G'!'. TWO) 1,0 TO 10
HOTL2210
IAPFX=-2
HOTL2220
HOTL2230
TP .LF. TN1
BFCAUS E 2
>.;OTE THAT TN1 • GT.
HOTL2240
HOTL2250
A"=TN1-0NE
HOTL2260
W=U/ (!ltTWO)
HOTL2270
BFTA=CI:lF (A 1 ,TN2)
HOTL2280
~F5M1=BETAIN(W.A1,TN2,B~TA,:FAULT)
HOTL2290
IF (I?AULT • ~IE. 01 GO TO 20
HOTL230r
A 1=A.1/TWO
HOTL2310
A2=(TN?tONF)/TWO
HOTL2320
TFMP1=W*W
HOTL2330
BFTA=CfJF (A1 ,A2)
HOTL2340
TFR~2=BfTAI~(cEMP1.A1.A2,BETA,IFAULT)
HOTL2350
IF (HAULT • /lE. 0) GO TO 20
HOTL2360
COl
TFf ",2="ERM2*SQPTPr* EXP ( ALGAMA «TN1t'!'N2-0NE) /TWO)
HOTL2
1
-ALGA/'A (T N1/TWO) -ALGAMl\ (TN2/TWO)
HOTL2380
2 + «TN2-0NF) /TWO) *nOG «ON:S-W) / (ONFtW»)
HOTL2390
CDF=TFRM 1-TfRM2
HOTL2400
GO ~o 20
HOTL2410
HOTL2420
COMPUTE '1 (IN T"I) AND "I (IN TN)
HOTL2430
HOTL21i40
10
TM = (TN1-TP-ONE) /TWO
HOTL2450
TN = (TN2-TP-ONE)/TWO
HOTL21i60
IF TN .Lt:. 0 TilE FIRST MOMENT (TMU1) OF THE DISTFIBUrrON OF T (0) **2 HOTL2470
H01'L2480
DOES NOT EXIST AND THE APPROXI"lATION TECHNIQUE IS INVALID.
HOTL2490
HOTL2500
IF(TN .LF. ZFRO) GO TO 13
HOTL2510
TWOTN = TWO*TN
HOTL2520
TADD = TWO*TMtTP+ONE
HOTL2530
T~U1
~P*TAID/TWOTN
HOTL2540
HOTL2550
IF ,"I .1.3. 1 TIlE SECOND MOME"H (TMU2) DOES NO":' EXIST
HOTL2560
HOTL2570
IF(TN .LE. ONE)GO T0 12
HOTL2580
T"!U2 = 1M U1 * crWOTNtTADD) * (TliOTN+TP) / (TWOTN* (T N-ONE). (TWOTNt-ONE) )
HO'l'L?'i90
'l'Mfl1 SO= 1'''l1l1*1'MlJ1
I? N1
.LT.
IP,
=
=
=
=
=
=
C
C
C
=
c
C
C
c
C
C
nc
c
C
C
C
C
C
C
c
C
C
=
22
SUB R0 UTI NE HOT ELL LIS TIN G
C
C
C
C
C
C
c
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
HOTL2600
IiOTL2610
HOTL2620
IF (TN • LE. TWO) GO "'0 11
HOTL2630
'eMU3 = (TWO*TM02* (":'NHADO) * (TNtTP»1 (TN* (TN-TWO) * (TNtONF»
HOTL264C
T~U2SQ = TMU2*TMU2
HOTL2650
HOTL266(1
COMPUTE A A~D 3 FOR THE THREE-MOMENT APPROXIMATION
HOTL2610
HOTL2680
A = (~!'IU1*(-SIX*TMU2SQ+TMU1*(THREE*TMU3tTWO*TI'!U1*TMU2» -TMU2*TMU3) HOTL2690
1
I(T~U2*TMU1~FOUR*T!U1*TMU2SQ-TMU'SQ*TMU3)
HOTL2100
B
( (1\tONE) * (AtTH"EE) -TMU1 SQ/T MU211 ( (AtONE I -T MU 1SQ/T MU 21
HOTL2110
HOTL2120
CHECK FO~ (3- A) • LF:. 4
HOTL2730
HOTL2140
IF (B-A .LE. FaUl'l GO ':'0 11
HOTL2150
IAPRX = 3
HOTL2760
TK = TMU1* (B-A-TWO)/(AtONEI
HOTL2110
w=U/(UtTK)
HOTL2180
HOTL2790
W IS TH! UPPER LIMIT FOR USE WIT" THE CUMULATIVE DISTRIBUTION
HOTL2800
FUNCTION OF THE
BFTA(A1.B11
DISTRIBUTION;
HOT12810
HOTL2A20
P!'(T(O)**2 .LT. T) = PReBETA .LT. WI. APPROXIMATELY
HOTL2810
HOTL2840
GO TO 14
HOTL2850
HOT12860
COM~UTE A AND B FOR THE T~O-MOMENT APPROXIMATION
HOT12870
HOTL2880
TEMP1 = TP*TMJ2
HOTL2890
11
A
(TMU2* (TMU1-TPI +TMU1 SQ* (TMU1tTP)I/TEMP1
HOTL290C
II = (TMU1*(TMIJ1+TPI**2trMU1*TMU2tTWO*TEMP1)/TEr'lP1
HOTL2910
HOTL2920
CHECK FOP B-)l. .L~. 3
HOTL2930
HOTL2940
IF (B-A .LE. ':'HHEI GO TO 12
HOTL2950
!APFX = ?
HOTL2960
w=U/{Ut"'PI
HOTL2970
GO ~o 14
HOTL2980
HOTL29':"10
COMPUTE A AND B FOR THE C~E-MOMENT APPROXIMATION
HOTL3000
HOTL3010
12 A
TP*TADD/TWO-0NE
HOTL3020
B
TP*(TADD+TWOTNI/TWOtONE
HOTL3030
HOTL3040
CHECK FOR B-A .LE. 2
HOTL3050
HOTL3060
1'" (8-A • LEo TWO) GO TO 13
HOTL3070
IAPPX = 1
HOTL3080
W=U/(Utmp)
HOTL3090
GO TO 14
HOTL3100
HOTL3 1 10
wilEN B-JI. • LE. 2 THE Jl.PPROXIMA'l'ION TECHNIQUE IS NOT APPLICABLE.
HOTL3120
HOTL3130
13 IAPFX = 0
HOTL3140
:FAULT = 1
HOTL3150
GO TO 20
HOTL3 160
14 A1=J\.tONE
HOTL3170
B1=B-A-ONE
HOTL3180
HOTL3190
A CHFCK IS "'ADE TO INSUPE THAT THE PHAMETERS
W, A1. B1.
ARE
HOTL3200
WITHIN THE PJ\.NGE OF THE rNCO~PLETE BETA FUNCTION.
HOT13210
H01L3220
15 IF (W .LT. ZEROI GO TO 20
HOTL3230
IF (Jl.1 .LE. ZEF.O .OR. B1 .L". ZERO) GO TO 20
HOTL3240
a~'l' 1'.=Caf (A 1 -IH)
Hon l 7C;O
IF TN
.L2.
~
~HE THIRD
MOMENT
(TM1I3)
DOES NOT EXIST
23
SUB ROUT I NE HOT ELL LIS TIN G
CDF=BRTAIN (W,A1 ,61, BETA, IFAULT)
HIIF1IULT .N~. n) CDP = -1E75
20 FFTUR'l
END
HOTL3261)
HOTL3270
HOTL3280
HOTL3290
24
SUB ROUT I NEB ETA I N LIS TIN G
c***
FUNCTllN
HETAIN(X,P,Q,BETA,IFAULT)
c
C
H.;Or:':THM AS 63
c
c
CO~?UTES
c
COt1PLETl
APPL STATIST.
(1973),
VOL.22,
INCOMPLETE HETA INTEGRAL rOj ARGUMENTS
.~lj D V POSITIVE.
BETA FUNCTION IS ,\SSUMED 70 DC KN ),;~.
x iJETWEEN lEBO AND (,NE, P
C
LOGICAL INDEX
.::
DSFINE ACCURACY
C
C
AND
INIrIAL~SE
Aeu
DAT~
/0.1E-7/
BETAIN = X
C
C
C
TEST FOR ADMISSIBILITY OF ARGUMENTS
'}:'
d ~ ~ r.
J.':-:' A
6C
[jETA
8C
70
;;:::1' .~
q,)
dETA
6ETA
100
110
BET .r,
120
REB
130
i3E.~
1bi'l
HI:.:n 1fl(
HTH.N
Sf,"A
190
i3ETA
200
RETIRN
dEfA 210
d:':'" A 22C
" ET ,J F N
CX
x
BETA 230
BETA 240
BETA 25G
aET .~ 260
iJETA 270
BETA 280
31,1'A 290
3ErA 30u
dETA 31ti
PP
Q
i3 PTA
2Q
P
x
JE:' A HJ
LlLTA 34,)
riP." A ~50
"E:'A 36')
P
Q
JETA
H;orA
380
i3ET~
39C
CHANGE TAIL
IF
~ECFSS~~Y
AND
DETERMINE S
PSQ = ~ + Q
CX=1.0-X
If
(P. GE. PSQ*X)
xx
GC m .) 1
ex
INDH
=
.TRUE.
GOTO 2
XX
Pi'
iJQ
=
=
=
INDEX
.FALSE.
? TEPl = 1.0
AI = 1.0
32C
37,'
BETA 4('''
dEl' A 410
RETAIN = 1.0
NS = QQ
ex
*
+
iJl'rA
d"T .~
PSQ
420
430
440
[j:::T A 45,)
RETA 460
llETA 470
'lLTA 4tle
BETA l;'1J
ilE:'A 500
tlEB S1 C'
I:lI:TA <;20
BETA 53"
LIE'! A :'40
f! ETA
c
USE SOPER-S
C
RX
=
3 rEM P
R£CUCTION FORMULAE.
xx/ex
=
QQ - AI
(NS.EQ.O) RX = XX
4 T~FM = TEFM
TF~P
PX / (PP + AI)
BETAIN
BFTAIN + TER~
TEMP = ABS(TERt'!)
If ("EMP.LE.ACU.A~JD.TE"'P.LE,AC[J*I:lETAIN)GO TO 5
AI = AI + 1.0
NS = NS - 1
IF (NS.GE.O) GOTO 3
IF
*
=
TFMP
PSQ
= l'SI.l
=
PSQ
+
1.0
GOTO 4
c
C
'F
4e
,3 LT A 17r
IFAIJLT = 1
(P.LE.O.O.OI\,Q.LE.C.J)
IrAULT = 2
I f (X.LT.O.0.OR.X.GT.1.0)
IFAUL'" = 0
IF ( X • ,; v• O. O. 0 P • X. E Q• 1 • 0 )
C
"
1"
20
BETA 11..0
LlI:TA 1 S')
IF
c
NO.3
3 i.T_~
LJ t. ~~ f.,
dE'n.
,,':-TA.
,ETA
J i'I'!.
CALClILATf: RrSULT
*
J:E:'A
SSG
J1:TA
51)O
3E.~
570
nTA 580
BErA 590
!nT.~ 600
dETA 610
BETA 620
25
SUBROUTINE
r.,
BET.~IN
LISTING
:J TAB = Bt:"'A:::N * ~:Xi'(['p*r.Lr)r,(XX)t<\,lQ-1.01*ALJ~;(CX)I/([,p*.,:T!1)
I
(!~DEX)
R~TAIN
= 1.0 - B:-:TAI~
b
TUi\N
~'1D
nl:T.~
t,3C
:3~T~
(4)
lH'~!I
6<;)
bETA
of,"
26
THE FOLLOWING RESULTS OBTAINED FROM SUBROUTINE HOTELL AGREE WITH THOSE
OF TABLE II IN PILLAI AND YOUNG (1971)
N1
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
5
5
5
5
5
5
5
5
5
5
N2
14
14
24
24
34
34
44
44
64
64
84
84
104
104
124
124
164
164
204
204
14
14
24
24
34
34
44
44
64
64
84
84
104
104
124
124
164
164
204
204
15
15
25
25
35
35
45
45
65
65
P
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
T/N2
2.5064
3.6951
1. 1562
1.5623
.74777
.98252
.55207
.71559
.36218
.46326
.26943
.34239
.21449
.27151
.17815
.22494
.13306
.16748
.10619
.13340
5.4723
7.6114
2.4700
3.1258
1.5845
.19465
1.1649
1.4107
.76090
.90866
.56480
.66987
.44901
.53039
.37261
.43896
.27799
.32640
.22168
.25977
3.8146
5.3980
1.7419
2.2532
1.1230
1.4127
.82786
1.0277
.54237
.66464
CDF
.949997
.990000
.949993
.990000
.950001
.990000
.950001
.990000
.949999
.990000
.949997
.990000
.950002
.989998
.949996
.989999
.949992
.990001
.950009
.990002
.949998
.990000
.950005
.990000
.950006
.989999
.950006
.990003
.949997
.990000
.950003
.990000
.949997
.990000
.950000
.990000
.950004
.990001
.949991
.989998
.950001
.990000
.950004
.990001
.950008
.989999
.949999
.990003
.950001
.990000
27
Nl
5
5
5
5
5
5
5
5
5
5
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
N2
85
85
105
105
125
125
165
165
205
205
15
15
25
25
35
35
45
45
65
65
85
85
105
105
125
125
165
165
205
205
P
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
T/N2
.40321
.49103
.32087
.38930
.26645
.32248
.19895
.24007
.15874
. 19120
6.3433
8.6636
2.8631
3.5626
1.8384
2.2236
1.3525
1.6140
.88428
1.0416
.65673
.76869
.52228
.60905
.43352
.50430
.32353
.37521
.25806
.29874
CDF
.949996
.990000
.950002
.989999
.950005
.989999
.949998
.990001
.950005
.990001
.950001
.990000
.950001
.990001
.950004
.990002
.949994
.990002
.949999
.990001
.950001
.990000
.949997
.990000
.950002
.990001
.949997
.990000
.950006
.990002