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_rand_copula_clayton (g05rh)

Purpose

nag_rand_copula_clayton (g05rh) generates pseudorandom uniform variates with joint distribution of a Clayton/Cook–Johnson Archimedean copula.

Syntax

[state, x, ifail] = g05rh(n, m, theta, sorder, state)
[state, x, ifail] = nag_rand_copula_clayton(n, m, theta, sorder, state)

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 functions nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_copula_clayton (g05rh).

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

Parameters

Compulsory Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
$n$, the number of pseudorandom uniform variates to generate.
Constraint: ${\mathbf{n}}\ge 0$.
2:     $\mathrm{m}$int64int32nag_int scalar
$m$, the number of dimensions.
Constraint: ${\mathbf{m}}\ge 2$.
3:     $\mathrm{theta}$ – double scalar
$\theta$, the copula parameter.
Constraint: ${\mathbf{theta}}\ge 1.0×{10}^{-6}$.
4:     $\mathrm{sorder}$int64int32nag_int scalar
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)$int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.

None.

Output Parameters

1:     $\mathrm{state}\left(:\right)$int64int32nag_int array
Contains updated information on the state of the generator.
2:     $\mathrm{x}\left(\mathit{ldx},\mathit{sdx}\right)$ – double array
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$.
3:     $\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$
On entry, corrupt state argument.
${\mathbf{ifail}}=2$
Constraint: ${\mathbf{theta}}\ge 1.0×{10}^{-6}$.
${\mathbf{ifail}}=3$
Constraint: ${\mathbf{n}}\ge 0$.
${\mathbf{ifail}}=4$
Constraint: ${\mathbf{m}}\ge 2$.
${\mathbf{ifail}}=5$
On entry, invalid sorder.
Constraint: ${\mathbf{sorder}}=1$ or $2$.
${\mathbf{ifail}}=7$
On entry, ldx is too small: $\mathit{ldx}=_$.
${\mathbf{ifail}}=8$
On entry, sdx is too small: $\mathit{sdx}=_$.
${\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

Not applicable.

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

Example

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

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

% Initialize the base generator to a repeatable sequence
seed  = [int64(1762543)];
genid = int64(1);
subid = int64(1);
[state, ifail] = g05kf( ...
genid, subid, seed);

% Sample size
n = int64(13);
m = int64(4);
% Sample order
sorder = int64(1);

% Parameter
theta = 1.3;

% Generate variates
[state, x, ifail] = g05rh( ...
n, m, theta, sorder, state);

disp('Variates from a Clayton/Cook–Johnson copula');
disp(x);

```
```g05rh example results

Variates from a Clayton/Cook–Johnson copula
0.8576    0.5048    0.9761    0.5895
0.3186    0.6372    0.9959    0.5898
0.9050    0.6950    0.9353    0.9329
0.5278    0.1804    0.4177    0.2330
0.1510    0.9777    0.2621    0.3867
0.3906    0.7938    0.3073    0.3150
0.1279    0.1709    0.1751    0.0568
0.7613    0.4314    0.3498    0.2913
0.3871    0.4430    0.3610    0.3774
0.1242    0.0647    0.0472    0.0780
0.6866    0.9500    0.9289    0.9763
0.5259    0.8218    0.7134    0.4914
0.0955    0.0459    0.1265    0.1947

```