NAG FL Interface
g01jdf (prob_​chisq_​lincomb)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01jdf calculates the lower tail probability for a linear combination of (central) χ2 variables.

2 Specification

Fortran Interface
Subroutine g01jdf ( method, n, rlam, d, c, prob, work, ifail)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: rlam(n), d, c
Real (Kind=nag_wp), Intent (Out) :: prob, work(n+1)
Character (1), Intent (In) :: method
C Header Interface
#include <nag.h>
void  g01jdf_ (const char *method, const Integer *n, const double rlam[], const double *d, const double *c, double *prob, double work[], Integer *ifail, const Charlen length_method)
The routine may be called by the names g01jdf or nagf_stat_prob_chisq_lincomb.

3 Description

Let u1,u2,,un be independent Normal variables with mean zero and unit variance, so that u12,u22,,un2 have independent χ2-distributions with unit degrees of freedom. g01jdf evaluates the probability that
λ1u12+λ2u22++λnun2<d(u12+u22++un2)+c.  
If c=0.0 this is equivalent to the probability that
λ1u12+λ2u22++λnun2 u12+u22++un2 <d.  
Alternatively let
λi*=λi-d,   ​ i= 1,2,,n,  
then g01jdf returns the probability that
λ1*u12+λ2*u22++λn*un2<c.  
Two methods are available. One due to Pan (1964) (see Farebrother (1980)) makes use of series approximations. The other method due to Imhof (1961) reduces the problem to a one-dimensional integral. If n6 then a non-adaptive method described in d01bdf is used to compute the value of the integral otherwise d01ajf is used.
Pan's procedure can only be used if the λi* are sufficiently distinct; g01jdf requires the λi* to be at least 1% distinct; see Section 9. If the λi* are at least 1% distinct and n60, then Pan's procedure is recommended; otherwise Imhof's procedure is recommended.

4 References

Farebrother R W (1980) Algorithm AS 153. Pan's procedure for the tail probabilities of the Durbin–Watson statistic Appl. Statist. 29 224–227
Imhof J P (1961) Computing the distribution of quadratic forms in Normal variables Biometrika 48 419–426
Pan Jie–Jian (1964) Distributions of the noncircular serial correlation coefficients Shuxue Jinzhan 7 328–337

5 Arguments

1: method Character(1) Input
On entry: indicates whether Pan's, Imhof's or an appropriately selected procedure is to be used.
method='P'
Pan's method is used.
method='I'
Imhof's method is used.
method='D'
Pan's method is used if λi*, for i=1,2,,n are at least 1% distinct and n60; otherwise Imhof's method is used.
Constraint: method='P', 'I' or 'D'.
2: n Integer Input
On entry: n, the number of independent standard Normal variates, (central χ2 variates).
Constraint: n1.
3: rlam(n) Real (Kind=nag_wp) array Input
On entry: the weights, λi, for i=1,2,,n, of the central χ2 variables.
Constraint: rlam(i)d for at least one i. If method='P', the λi* must be at least 1% distinct; see Section 9, for i=1,2,,n.
4: d Real (Kind=nag_wp) Input
On entry: d, the multiplier of the central χ2 variables.
Constraint: d0.0.
5: c Real (Kind=nag_wp) Input
On entry: c, the value of the constant.
6: prob Real (Kind=nag_wp) Output
On exit: the lower tail probability for the linear combination of central χ2 variables.
7: work(n+1) Real (Kind=nag_wp) array Workspace
8: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, d=value.
Constraint: d0.0.
On entry, method=value.
Constraint: method='P', 'I' or 'D'.
On entry, n=value.
Constraint: n1.
ifail=2
On entry, rlam(i)=d for all values of i, for i=1,2,,n.
ifail=3
On entry, method='P' but two successive values of λ* were not 1 percent distinct.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

On successful exit at least four decimal places of accuracy should be achieved.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g01jdf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

Pan's procedure can only work if the λi* are sufficiently distinct. g01jdf uses the check |wj-wj-1|0.01×max(|wj|,|wj-1|), where the wj are the ordered nonzero values of λi*.
For the situation when all the λi are positive g01jcf may be used. If the probabilities required are for the Durbin–Watson test, then the bounds for the probabilities are given by g01epf.

10 Example

For n=10, the choice of method, values of c and d and the λi are input and the probabilities computed and printed.

10.1 Program Text

Program Text (g01jdfe.f90)

10.2 Program Data

Program Data (g01jdfe.d)

10.3 Program Results

Program Results (g01jdfe.r)