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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_rand_copula_frank (g05rj)

## Purpose

nag_rand_copula_frank (g05rj) generates pseudorandom uniform variates with joint distribution of a Frank Archimedean copula.

## Syntax

[state, x, ifail] = g05rj(n, m, theta, sorder, state)
[state, x, ifail] = nag_rand_copula_frank(n, m, theta, sorder, state)

## Description

Generates n$n$ pseudorandom uniform m$m$-variates whose joint distribution is the Frank Archimedean copula Cθ${C}_{\theta }$, given by
Cθ = − 1/θ ln[1 + ( (e − θu_1 − 1) (e − θu_2 − 1) ⋯ (e − θu_m − 1) )/( (e − θ − 1)m − 1 )] ,
 { θ ∈ (0,∞) , uj ∈ (0,1] ,   j = 1 , … m ;
$Cθ = - 1θ ln[ 1 + ( e -θu1 -1 ) ( e -θu2 -1 ) ⋯ ( e -θum -1 ) ( e-θ - 1 ) m-1 ] , { θ ∈ (0,∞) , uj ∈ (0,1] , j = 1 , … m ;$
with the special case:
• C = min (u1,u2,,um) ${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_frank (g05rj).

## 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:     n – int64int32nag_int scalar
n$n$, the number of pseudorandom uniform variates to generate.
Constraint: n0${\mathbf{n}}\ge 0$.
2:     m – int64int32nag_int scalar
m$m$, the number of dimensions.
Constraint: m2${\mathbf{m}}\ge 2$.
3:     theta – double scalar
θ$\theta$, the copula parameter.
Constraint: theta1.0 × 106${\mathbf{theta}}\ge 1.0×{10}^{-6}$.
4:     sorder – int64int32nag_int scalar
Determines the storage order of variates; the (i,j)$\left(\mathit{i},\mathit{j}\right)$th variate is stored in x(i,j)${\mathbf{x}}\left(\mathit{i},\mathit{j}\right)$ if sorder = 1${\mathbf{sorder}}=1$, and x(j,i)${\mathbf{x}}\left(\mathit{j},\mathit{i}\right)$ if sorder = 2${\mathbf{sorder}}=2$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$ and j = 1,2,,m$\mathit{j}=1,2,\dots ,m$.
Constraint: sorder = 1${\mathbf{sorder}}=1$ or 2$2$.
5:     state( : $:$) – 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.

ldx sdx

### Output Parameters

1:     state( : $:$) – 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 updated information on the state of the generator.
2:     x(ldx,sdx) – double array
The pseudorandom uniform variates with joint distribution described by Cθ${C}_{\theta }$, with x(i,j)${\mathbf{x}}\left(i,j\right)$ holding the i$i$th value for the j$j$th dimension if sorder = 1${\mathbf{sorder}}=1$ and the j$j$th value for the i$i$th dimension of sorder = 2${\mathbf{sorder}}=2$.
3:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail = 1${\mathbf{ifail}}=1$
On entry, corrupt state parameter.
ifail = 2${\mathbf{ifail}}=2$
Constraint: theta1.0 × 106${\mathbf{theta}}\ge 1.0×{10}^{-6}$.
ifail = 3${\mathbf{ifail}}=3$
Constraint: n0${\mathbf{n}}\ge 0$.
ifail = 4${\mathbf{ifail}}=4$
Constraint: m > 1${\mathbf{m}}>1$.
ifail = 5${\mathbf{ifail}}=5$
Invalid storage option.
ifail = 7${\mathbf{ifail}}=7$
On entry, ldx is too small: .
ifail = 8${\mathbf{ifail}}=8$
On entry, sdx is too small: .
ifail = 999${\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 θ1.0 × 106$\theta \ge 1.0×{10}^{-6}$;
• if θ > lnε$\theta >-\mathrm{ln}\epsilon$, the function returns pseudorandom uniform variates with C${C}_{\infty }$ joint distribution;
where ε$\epsilon$ is the machine precision returned by nag_machine_precision (x02aj).

## Example

```function nag_rand_copula_frank_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);
% Sample size
n = int64(13);
m = int64(4);
% Sample order
sorder = int64(1);
% Parameter
theta = 4;

% Initialize the generator to a repeatable sequence
[state, ifail] = nag_rand_init_repeat(genid, subid, seed);

% Generate variates
[state, x, ifail] = nag_rand_copula_frank(n, m, theta, sorder, state)
```
```

state =

17
1234
1
0
19862
26460
32347
15920
17917
13895
19930
8
0
1234
1
1
1234

x =

0.5679    0.1977    0.8682    0.2664
0.0965    0.3532    0.9773    0.3102
0.5526    0.2562    0.6341    0.6267
0.8036    0.4747    0.7310    0.5515
0.2043    0.9797    0.3628    0.4968
0.4777    0.8146    0.3922    0.4005
0.4162    0.5002    0.5074    0.2008
0.3703    0.0971    0.0527    0.0278
0.4354    0.4880    0.4096    0.4259
0.2693    0.1169    0.0639    0.1555
0.0127    0.3080    0.2352    0.4659
0.0730    0.3239    0.2020    0.0568
0.2369    0.0817    0.3118    0.4370

ifail =

0

```
```function g05rj_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);
% Sample size
n = int64(13);
m = int64(4);
% Sample order
sorder = int64(1);
% Parameter
theta = 4;

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

% Generate variates
[state, x, ifail] = g05rj(n, m, theta, sorder, state)
```
```

state =

17
1234
1
0
19862
26460
32347
15920
17917
13895
19930
8
0
1234
1
1
1234

x =

0.5679    0.1977    0.8682    0.2664
0.0965    0.3532    0.9773    0.3102
0.5526    0.2562    0.6341    0.6267
0.8036    0.4747    0.7310    0.5515
0.2043    0.9797    0.3628    0.4968
0.4777    0.8146    0.3922    0.4005
0.4162    0.5002    0.5074    0.2008
0.3703    0.0971    0.0527    0.0278
0.4354    0.4880    0.4096    0.4259
0.2693    0.1169    0.0639    0.1555
0.0127    0.3080    0.2352    0.4659
0.0730    0.3239    0.2020    0.0568
0.2369    0.0817    0.3118    0.4370

ifail =

0

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013