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:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the number of pseudorandom uniform variates to generate.
Constraint: ${\mathbf{N}}\ge 0$.
2:     $\mathrm{M}$ – INTEGERInput
On entry: $m$, the number of dimensions.
Constraint: ${\mathbf{M}}\ge 2$.
3:     $\mathrm{THETA}$ – REAL (KIND=nag_wp)Input
On entry: $\theta$, the copula parameter.
Constraint: ${\mathbf{THETA}}\ge 1.0×{10}^{-6}$.
4:     $\mathrm{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:     $\mathrm{STATE}\left(*\right)$ – 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:     $\mathrm{X}\left({\mathbf{LDX}},{\mathbf{SDX}}\right)$ – 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:     $\mathrm{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:     $\mathrm{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:     $\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, corrupt STATE parameter.
${\mathbf{IFAIL}}=2$
On entry, invalid THETA: ${\mathbf{THETA}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{THETA}}\ge 1.0×{10}^{-6}$.
${\mathbf{IFAIL}}=3$
On entry, ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{N}}\ge 0$.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{M}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{M}}\ge 2$.
${\mathbf{IFAIL}}=5$
On entry, invalid SORDER.
Constraint: ${\mathbf{SORDER}}=1$ or $2$.
${\mathbf{IFAIL}}=7$
On entry, LDX must be at least $〈\mathit{\text{value}}〉$: ${\mathbf{LDX}}=〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=8$
On entry, SDX must be at least $〈\mathit{\text{value}}〉$: ${\mathbf{SDX}}=〈\mathit{\text{value}}〉$.
${\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.

Not applicable.

## 8  Parallelism and Performance

G05RHF 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.

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.

## 10  Example

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

### 10.1  Program Text

Program Text (g05rhfe.f90)

### 10.2  Program Data

Program Data (g05rhfe.d)

### 10.3  Program Results

Program Results (g05rhfe.r)