G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01HDF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G01HDF returns a probability associated with a multivariate Student's $t$-distribution.

## 2  Specification

 FUNCTION G01HDF ( N, TAIL, A, B, NU, DELTA, ISCOV, RC, LDRC, EPSABS, EPSREL, NUMSUB, NSAMPL, FMAX, ERREST, IFAIL)
 REAL (KIND=nag_wp) G01HDF
 INTEGER N, ISCOV, LDRC, NUMSUB, NSAMPL, FMAX, IFAIL REAL (KIND=nag_wp) A(N), B(N), NU, DELTA(N), RC(LDRC,N), EPSABS, EPSREL, ERREST CHARACTER(1) TAIL(N)

## 3  Description

A random vector $x\in {ℝ}^{n}$ that follows a Student's $t$-distribution with $\nu$ degrees of freedom and covariance matrix $\Sigma$ has density:
 $Γ ν+n / 2 Γ ν/2 νn/2 πn/2 Σ 1/2 1+ 1ν xT Σ-1x ν+n / 2 ,$
and probability $p$ given by:
 $p = Γ ν+n / 2 Γ ν/2 Σ πνn ∫ a1 b1 ∫ a2 b2 ⋯ ∫ an bn 1+ xT Σ-1x/ν - ν+n/2 dx .$
The method of calculation depends on the dimension $n$ and degrees of freedom $\nu$. The method of Dunnet and Sobel is used in the bivariate case if $\nu$ is a whole number. A Plackett transform followed by quadrature method is adopted in other bivariate cases and trivariate cases. In dimensions higher than three a number theoretic approach to evaluating multidimensional integrals is adopted.
Error estimates are supplied as the published accuracy in the Dunnet and Sobel case, a Monte–Carlo standard error for multidimensional integrals, and otherwise the quadrature error estimate.
A parameter $\delta$ allows for non-central probabilities. The number theoretic method is used if any $\delta$ is nonzero.
In cases other than the central bivariate with whole $\nu$, G01HDF attempts to evaluate probabilities within a requested accuracy $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\epsilon }_{a},{\epsilon }_{r}×I\right)$, for an approximate integral value $I$, absolute accuracy ${\epsilon }_{a}$ and relative accuracy ${\epsilon }_{r}$.

## 4  References

Dunnet C W and Sobel M (1954) A bivariate generalization of Student's $t$-distribution, with tables for certain special cases Biometrika 41 153–169
Genz A and Bretz F (2002) Methods for the computation of multivariate $t$-probabilities Journal of Computational and Graphical Statistics (11) 950–971

## 5  Parameters

1:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the number of dimensions.
Constraint: $1<{\mathbf{N}}\le 1000$.
2:     $\mathrm{TAIL}\left({\mathbf{N}}\right)$ – CHARACTER(1) arrayInput
On entry: defines the calculated probability, set ${\mathbf{TAIL}}\left(i\right)$ to:
${\mathbf{TAIL}}\left(i\right)=\text{'L'}$
If the $i$th lower limit ${a}_{i}$ is negative infinity.
${\mathbf{TAIL}}\left(i\right)=\text{'U'}$
If the $i$th upper limit ${b}_{i}$ is infinity.
${\mathbf{TAIL}}\left(i\right)=\text{'C'}$
If both ${a}_{i}$ and ${b}_{i}$ are finite.
Constraint: ${\mathbf{TAIL}}\left(\mathit{i}\right)=\text{'L'}$, $\text{'U'}$ or $\text{'C'}$, for $\mathit{i}=1,2,\dots ,{\mathbf{N}}$.
3:     $\mathrm{A}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: ${a}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, the lower integral limits of the calculation.
If ${\mathbf{TAIL}}\left(i\right)=\text{'L'}$, ${\mathbf{A}}\left(i\right)$ is not referenced and the $i$th lower limit of integration is $-\infty$.
4:     $\mathrm{B}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: ${b}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, the upper integral limits of the calculation.
If ${\mathbf{TAIL}}\left(i\right)=\text{'U'}$, ${\mathbf{B}}\left(i\right)$ is not referenced and the $i$th upper limit of integration is $\infty$.
Constraint: if ${\mathbf{TAIL}}\left(i\right)=\text{'C'}$, ${\mathbf{B}}\left(i\right)>{\mathbf{A}}\left(i\right)$.
5:     $\mathrm{NU}$ – REAL (KIND=nag_wp)Input
On entry: $\nu$, the degrees of freedom.
Constraint: ${\mathbf{NU}}>0.0$.
6:     $\mathrm{DELTA}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{DELTA}}\left(\mathit{i}\right)$ the noncentrality parameter for the $\mathit{i}$th dimension, for $\mathit{i}=1,2,\dots ,{\mathbf{N}}$; set ${\mathbf{DELTA}}\left(i\right)=0$ for the central probability.
7:     $\mathrm{ISCOV}$ – INTEGERInput
On entry: set ${\mathbf{ISCOV}}=1$ if the covariance matrix is supplied and ${\mathbf{ISCOV}}=2$ if the correlation matrix is supplied.
Constraint: ${\mathbf{ISCOV}}=1$ or $2$.
8:     $\mathrm{RC}\left({\mathbf{LDRC}},{\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput/Output
On entry: the lower triangle of either the covariance matrix (if ${\mathbf{ISCOV}}=1$) or the correlation matrix (if ${\mathbf{ISCOV}}=2$). In either case the array elements corresponding to the upper triangle of the matrix need not be set.
On exit: the strict upper triangle of RC contains the correlation matrix used in the calculations.
9:     $\mathrm{LDRC}$ – INTEGERInput
On entry: the first dimension of the array RC as declared in the (sub)program from which G01HDF is called.
Constraint: ${\mathbf{LDRC}}\ge {\mathbf{N}}$.
10:   $\mathrm{EPSABS}$ – REAL (KIND=nag_wp)Input
On entry: ${\epsilon }_{a}$, the absolute accuracy requested in the approximation. If EPSABS is negative, the absolute value is used.
Suggested value: $0.0$.
11:   $\mathrm{EPSREL}$ – REAL (KIND=nag_wp)Input
On entry: ${\epsilon }_{r}$, the relative accuracy requested in the approximation. If EPSREL is negative, the absolute value is used.
Suggested value: $0.001$.
12:   $\mathrm{NUMSUB}$ – INTEGERInput
On entry: if quadrature is used, the number of sub-intervals used by the quadrature algorithm; otherwise NUMSUB is not referenced.
Suggested value: $350$.
Constraint: if referenced, ${\mathbf{NUMSUB}}>0$.
13:   $\mathrm{NSAMPL}$ – INTEGERInput
On entry: if quadrature is used, NSAMPL is not referenced; otherwise NSAMPL is the number of samples used to estimate the error in the approximation.
Suggested value: $8$
Constraint: if referenced, ${\mathbf{NSAMPL}}>0$.
14:   $\mathrm{FMAX}$ – INTEGERInput
On entry: if a number theoretic approach is used, the maximum number of evaluations for each integrand function.
Suggested value: $1000×{\mathbf{N}}$
Constraint: if referenced, ${\mathbf{FMAX}}\ge 1$.
15:   $\mathrm{ERREST}$ – REAL (KIND=nag_wp)Output
On exit: an estimate of the error in the calculated probability.
16:   $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
On entry, ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
Constraint: $1<{\mathbf{N}}\le 1000$.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{TAIL}}\left(k\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{TAIL}}\left(\mathit{k}\right)=\text{'L'}$, $\text{'U'}$ or $\text{'C'}$.
${\mathbf{IFAIL}}=4$
On entry, $k=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{B}}\left(k\right)>{\mathbf{A}}\left(k\right)$ for a central probability.
${\mathbf{IFAIL}}=5$
On entry, ${\mathbf{NU}}=〈\mathit{\text{value}}〉$.
Constraint: degrees of freedom ${\mathbf{NU}}>0.0$.
${\mathbf{IFAIL}}=8$
On entry, ${\mathbf{ISCOV}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ISCOV}}=1$ or $2$.
${\mathbf{IFAIL}}=9$
On entry, the information supplied in RC is invalid.
${\mathbf{IFAIL}}=10$
On entry, ${\mathbf{LDRC}}=〈\mathit{\text{value}}〉$ and ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{LDRC}}\ge {\mathbf{N}}$.
${\mathbf{IFAIL}}=12$
On entry, ${\mathbf{NUMSUB}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NUMSUB}}\ge 1$.
${\mathbf{IFAIL}}=13$
On entry, ${\mathbf{NSAMPL}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NSAMPL}}\ge 1$.
${\mathbf{IFAIL}}=14$
On entry, ${\mathbf{FMAX}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{FMAX}}\ge 1$.
${\mathbf{IFAIL}}=-99$
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

## 7  Accuracy

An estimate of the error in the calculation is given by the value of ERREST on exit.

Not applicable.

None.

## 10  Example

This example prints two probabilities from the Student's $t$-distribution.

### 10.1  Program Text

Program Text (g01hdfe.f90)

### 10.2  Program Data

Program Data (g01hdfe.d)

### 10.3  Program Results

Program Results (g01hdfe.r)