G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG05RHF

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

G05RHF generates pseudorandom uniform variates with joint distribution of a Clayton/Cook–Johnson Archimedean copula.

## 2  Specification

 SUBROUTINE G05RHF ( N, M, THETA, SORDER, STATE, X, LDX, SDX, IFAIL)
 INTEGER N, M, SORDER, STATE(*), LDX, SDX, IFAIL REAL (KIND=nag_wp) THETA, X(LDX,SDX)

## 3  Description

Generates $n$ pseudorandom uniform $m$-variates whose joint distribution is the Clayton/Cook–Johnson Archimedean copula ${C}_{\theta }$, given by
 $Cθ = u1-θ + u2-θ + ⋯ + um-θ - m + 1 -1/θ , θ ∈ 0,∞ , uj ∈ 0,1 , j = 1 , … m ;$
with the special case:
• ${C}_{\infty }=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({u}_{1},{u}_{2},\dots ,{u}_{m}\right)$, the Fréchet–Hoeffding upper bound.
The generation method uses mixture of powers.
One of the initialization routines G05KFF (for a repeatable sequence if computed sequentially) or G05KGF (for a non-repeatable sequence) must be called prior to the first call to G05RHF.

## 4  References

Marshall A W and Olkin I (1988) Families of multivariate distributions Journal of the American Statistical Association 83 403
Nelsen R B (2006) An Introduction to Copulas (2nd Edition) Springer Series in Statistics

## 5  Parameters

1:     N – INTEGERInput
On entry: $n$, the number of pseudorandom uniform variates to generate.
Constraint: ${\mathbf{N}}\ge 0$.
2:     M – INTEGERInput
On entry: $m$, the number of dimensions.
Constraint: ${\mathbf{M}}\ge 2$.
3:     THETA – REAL (KIND=nag_wp)Input
On entry: $\theta$, the copula parameter.
Constraint: ${\mathbf{THETA}}\ge 1.0×{10}^{-6}$.
4:     SORDER – INTEGERInput
On entry: determines the storage order of variates; the $\left(\mathit{i},\mathit{j}\right)$th variate is stored in ${\mathbf{X}}\left(\mathit{i},\mathit{j}\right)$ if ${\mathbf{SORDER}}=1$, and ${\mathbf{X}}\left(\mathit{j},\mathit{i}\right)$ if ${\mathbf{SORDER}}=2$, for $\mathit{i}=1,2,\dots ,n$ and $\mathit{j}=1,2,\dots ,m$.
Constraint: ${\mathbf{SORDER}}=1$ or $2$.
5:     STATE($*$) – INTEGER arrayCommunication Array
Note: the actual argument supplied must be the array STATE supplied to the initialization routines G05KFF or G05KGF.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
6:     X(LDX,SDX) – REAL (KIND=nag_wp) arrayOutput
On exit: the pseudorandom uniform variates with joint distribution described by ${C}_{\theta }$, with ${\mathbf{X}}\left(i,j\right)$ holding the $i$th value for the $j$th dimension if ${\mathbf{SORDER}}=1$ and the $j$th value for the $i$th dimension of ${\mathbf{SORDER}}=2$.
7:     LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G05RHF is called.
Constraints:
• if ${\mathbf{SORDER}}=1$, ${\mathbf{LDX}}\ge {\mathbf{N}}$;
• if ${\mathbf{SORDER}}=2$, ${\mathbf{LDX}}\ge {\mathbf{M}}$.
8:     SDX – INTEGERInput
On entry: the second dimension of the array X as declared in the (sub)program from which G05RHF is called.
Constraints:
• if ${\mathbf{SORDER}}=1$, ${\mathbf{SDX}}\ge {\mathbf{M}}$;
• if ${\mathbf{SORDER}}=2$, ${\mathbf{SDX}}\ge {\mathbf{N}}$.
9:     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, STATE vector was not initialized or has been corrupted.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{THETA}}<1.0×{10}^{-6}$.
${\mathbf{IFAIL}}=3$
 On entry, ${\mathbf{N}}<0$.
${\mathbf{IFAIL}}=4$
 On entry, ${\mathbf{M}}<2$.
${\mathbf{IFAIL}}=5$
 On entry, ${\mathbf{SORDER}}\ne 1$ and ${\mathbf{SORDER}}\ne 2$.
${\mathbf{IFAIL}}=7$
 On entry, ${\mathbf{SORDER}}=1$ and ${\mathbf{LDX}}<{\mathbf{N}}$, or ${\mathbf{SORDER}}=2$ and ${\mathbf{LDX}}<{\mathbf{M}}$.
${\mathbf{IFAIL}}=8$
 On entry, ${\mathbf{SORDER}}=1$ and ${\mathbf{SDX}}<{\mathbf{M}}$, or ${\mathbf{SORDER}}=2$ and ${\mathbf{SDX}}<{\mathbf{N}}$.

## 7  Accuracy

Not applicable.

In practice, the need for numerical stability restricts the range of $\theta$ such that:
• the routine requires $\theta \ge 1.0×{10}^{-6}$;
• if $\theta >200.0$, the routine returns pseudorandom uniform variates with ${C}_{\infty }$ joint distribution.

## 9  Example

This example generates thirteen four-dimensional variates for copula ${C}_{1.3}$.

### 9.1  Program Text

Program Text (g05rhfe.f90)

### 9.2  Program Data

Program Data (g05rhfe.d)

### 9.3  Program Results

Program Results (g05rhfe.r)