Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_multi_students_t (g01hd)

## Purpose

nag_multi_students_t (g01hd) returns a probability associated with a multivariate Student's $t$-distribution.

## Syntax

[result, rc, errest, ifail] = g01hd(tail, a, b, nu, delta, iscov, rc, 'n', n, 'epsabs', epsabs, 'epsrel', epsrel, 'numsub', numsub, 'nsampl', nsampl, 'fmax', fmax)
[result, rc, errest, ifail] = nag_multi_students_t(tail, a, b, nu, delta, iscov, rc, 'n', n, 'epsabs', epsabs, 'epsrel', epsrel, 'numsub', numsub, 'nsampl', nsampl, 'fmax', fmax)

## 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$, nag_multi_students_t (g01hd) 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}$.

## 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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{tail}\left({\mathbf{n}}\right)$ – cell array of strings
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}}$.
2:     $\mathrm{a}\left({\mathbf{n}}\right)$ – double array
${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$.
3:     $\mathrm{b}\left({\mathbf{n}}\right)$ – double array
${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)$.
4:     $\mathrm{nu}$ – double scalar
$\nu$, the degrees of freedom.
Constraint: ${\mathbf{nu}}>0.0$.
5:     $\mathrm{delta}\left({\mathbf{n}}\right)$ – double array
${\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.
6:     $\mathrm{iscov}$int64int32nag_int scalar
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$.
7:     $\mathrm{rc}\left(\mathit{ldrc},{\mathbf{n}}\right)$ – double array
ldrc, the first dimension of the array, must satisfy the constraint $\mathit{ldrc}\ge {\mathbf{n}}$.
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.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the dimension of the arrays tail, a, b, delta and the first dimension of the array rc and the second dimension of the array rc. (An error is raised if these dimensions are not equal.)
$n$, the number of dimensions.
Constraint: $1<{\mathbf{n}}\le 1000$.
2:     $\mathrm{epsabs}$ – double scalar
Default: $0.0$
${\epsilon }_{a}$, the absolute accuracy requested in the approximation. If epsabs is negative, the absolute value is used.
3:     $\mathrm{epsrel}$ – double scalar
Default: $0.001$
${\epsilon }_{r}$, the relative accuracy requested in the approximation. If epsrel is negative, the absolute value is used.
4:     $\mathrm{numsub}$int64int32nag_int scalar
Default: $350$
If quadrature is used, the number of sub-intervals used by the quadrature algorithm; otherwise numsub is not referenced.
Constraint: if referenced, ${\mathbf{numsub}}>0$.
5:     $\mathrm{nsampl}$int64int32nag_int scalar
Default: $8$
If quadrature is used, nsampl is not referenced; otherwise nsampl is the number of samples used to estimate the error in the approximation.
Constraint: if referenced, ${\mathbf{nsampl}}>0$.
6:     $\mathrm{fmax}$int64int32nag_int scalar
Default: $1000×{\mathbf{n}}$
If a number theoretic approach is used, the maximum number of evaluations for each integrand function.
Constraint: if referenced, ${\mathbf{fmax}}\ge 1$.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.
2:     $\mathrm{rc}\left(\mathit{ldrc},{\mathbf{n}}\right)$ – double array
The strict upper triangle of rc contains the correlation matrix used in the calculations.
3:     $\mathrm{errest}$ – double scalar
An estimate of the error in the calculated probability.
4:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
Constraint: $1<{\mathbf{n}}\le 1000$.
${\mathbf{ifail}}=2$
Constraint: ${\mathbf{tail}}\left(\mathit{k}\right)=\text{'L'}$, $\text{'U'}$ or $\text{'C'}$.
${\mathbf{ifail}}=4$
Constraint: ${\mathbf{b}}\left(k\right)>{\mathbf{a}}\left(k\right)$ for a central probability.
${\mathbf{ifail}}=5$
Constraint: degrees of freedom ${\mathbf{nu}}>0.0$.
${\mathbf{ifail}}=8$
Constraint: ${\mathbf{iscov}}=1$ or $2$.
${\mathbf{ifail}}=9$
On entry, the information supplied in rc is invalid.
${\mathbf{ifail}}=10$
Constraint: $\mathit{ldrc}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=12$
Constraint: ${\mathbf{numsub}}\ge 1$.
${\mathbf{ifail}}=13$
Constraint: ${\mathbf{nsampl}}\ge 1$.
${\mathbf{ifail}}=14$
Constraint: ${\mathbf{fmax}}\ge 1$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

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

None.

## Example

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

fprintf('g01hd example results\n\n');

iscov  = int64(1);

% Example 1
nu    = 10;
tail  = {'u';  'u';  'u';  'u';  'u'};
a     = [-0.1; -0.1; -0.1; -0.1; -0.1];
b     = [888;  888;  888;  888;  888];
delta = [0;    0;    0;    0;    0];
rc    = [1.00, 0.75, 0.75, 0.75, 0.75;
0.75, 1.00, 0.75, 0.75, 0.75;
0.75, 0.75, 1.00, 0.75, 0.75;
0.75, 0.75, 0.75, 1.00, 0.75;
0.75, 0.75, 0.75, 0.75, 1.00];

% Calculate probability
[result, rc, errest, ifail] = ...
g01hd( ...
tail, a, b, nu, delta, iscov, rc);

fprintf('Example 1:\n');
fprintf('Probability:   %24.5e\nError estimate:%24.2e\n', result, errest);

% Example 2
nu = 3;
tail = {'l';   'l';  'l';  'l';  'l'};
a     = [888;  888;  888;  888;  888];
b     = [-0.1; -0.1; -0.1; -0.1; -0.1];
delta = [1;    2;    3;    3;    3];
rc    = [1.00, 0.75, 0.75, 0.75, 0.75;
0.75, 1.00, 0.75, 0.75, 0.75;
0.75, 0.75, 1.00, 0.75, 0.75;
0.75, 0.75, 0.75, 1.00, 0.75;
0.75, 0.75, 0.75, 0.75, 1.00];

% Calculate probability
[result, rc, errest, ifail] = ...
g01hd( ...
tail, a, b, nu, delta, iscov, rc);

fprintf('\nExample 2:\n');
fprintf('Probability:   %24.5e\nError estimate:%24.2e\n', result, errest);

```
```g01hd example results

Example 1:
Probability:                3.01642e-01
Error estimate:                1.09e-05

Example 2:
Probability:                8.62903e-05
Error estimate:                1.62e-07
```