NAG Library Routine Document G05REF.1

Similar documents
NAG Library Routine Document G05RGF.1

NAG Library Routine Document G05PZF.1

NAG Library Routine Document G05PZF.1

NAG Library Function Document nag_rand_bivariate_copula_frank (g05rfc)

NAG Library Routine Document G02BGF.1

NAG Library Function Document nag_rand_copula_clayton (g05rhc)

NAG Library Routine Document G02BXF.1

NAG Library Routine Document G05PGF.1

NAG Fortran Library Routine Document G05RAF.1

NAG Library Routine Document G01AJF.1

NAG Library Routine Document G01ABF.1

NAG Library Routine Document D02UCF.1

NAG Library Routine Document E02BCF.1

NAG Library Routine Document C05RBF.1

NAG Library Routine Document G13DMF.1

NAG Library Routine Document C05PBF/C05PBA

NAG Library Routine Document G02BUF.1

NAG Library Routine Document C05QBF.1

NAG Library Routine Document G13CDF.1

NAG Fortran Library Routine Document G01ADF.1

NAG Library Routine Document D02MWF.1

NAG Library Routine Document F04BEF.1

NAG Library Routine Document G12ABF.1

NAG Fortran Library Routine Document G05LZF.1

NAG Library Routine Document D02UAF.1

NAG Fortran Library Routine Document F01CTF.1

NAG Library Routine Document G02DAF.1

NAG Library Routine Document E04GYF.1

NAG Library Routine Document G13DPF.1

NAG Library Routine Document F07KDF (DPSTRF)

NAG Library Routine Document G02DDF.1

NAG Library Routine Document D04AAF.1

NAG Fortran Library Routine Document F04BGF.1

NAG Library Routine Document D02HBF.1

NAG Fortran Library Routine Document G01AJF.1

NAG Fortran Library Routine Document F04BJF.1

NAG Fortran Library Routine Document G02HKF.1

NAG Library Routine Document G02CFF.1

NAG Fortran Library Routine Document F01CWF.1

NAG Fortran Library Routine Document E02BCF.1

NAG Fortran Library Routine Document F04CAF.1

NAG Library Routine Document D01BAF.1

NAG Library Routine Document F04MCF.1

NAG Fortran Library Routine Document F04CJF.1

NAG Library Routine Document F08FAF (DSYEV)

NAG Library Routine Document F08LEF (DGBBRD)

NAG Library Function Document nag_rand_copula_normal (g05rdc)

NAG Fortran Library Routine Document G08AJF.1

NAG Fortran Library Routine Document F04DHF.1

NAG Fortran Library Routine Document F11ZPF.1

NAG Fortran Library Routine Document F04JAF.1

NAG Fortran Library Routine Document C05PBF.1

NAG Library Routine Document F04JAF.1

NAG Fortran Library Routine Document G08AKF.1

NAG Library Routine Document H02CFF.1

NAG Fortran Library Routine Document G01ARF.1

NAG Library Routine Document F08BVF (ZTZRZF)

NAG Library Routine Document G02GPF.1

NAG Library Routine Document F08ZNF (ZGGLSE)

NAG Library Routine Document F08FDF (DSYEVR)

NAG Fortran Library Routine Document F04JGF.1

NAG Library Routine Document E04WEF.1

NAG Library Routine Document E04GBF.1

NAG Fortran Library Routine Document G01NBF.1

NAG Fortran Library Routine Document X04CBF.1

NAG Library Routine Document H03ADF.1

NAG Fortran Library Routine Document D01AJF.1

NAG Library Routine Document E02DAF.1

NAG Fortran Library Routine Document D02MVF.1

NAG Fortran Library Routine Document D02PZF.1

NAG Fortran Library Routine Document F07AAF (DGESV).1

NAG Fortran Library Routine Document E01AEF.1

NAG Library Routine Document E02DFF.1

NAG Library Routine Document E04UDF/E04UDA

NAG Library Function Document nag_rand_2_way_table (g05pzc)

NAG Library Function Document nag_rngs_copula_students_t (g05rbc)

NAG Library Routine Document F07MAF (DSYSV).1

NAG Fortran Library Routine Document F08FQF (CHEEVD=ZHEEVD).1

NAG Fortran Library Routine Document D02KAF.1

NAG Fortran Library Routine Document F08BHF (DTZRZF).1

F01BSF NAG Fortran Library Routine Document

E02ZAF NAG Fortran Library Routine Document

NAG Library Routine Document F08NGF (DORMHR).1

C05 Roots of One or More Transcendental Equations. C05PCF NAG Fortran Library Routine Document

NAG Library Function Document nag_rgsn_matrix_multi_normal (g05lyc)

NAG Fortran Library Routine Document F11DSF.1

NAG Library Function Document nag_rand_arma (g05phc)

NAG Library Routine Document D02ZAF.1

NAG Library Function Document nag_5d_shep_eval (e01tnc)

NAG Library Function Document nag_nd_shep_eval (e01znc)

E04DGF NAG Fortran Library Routine Document

F02WUF NAG Fortran Library Routine Document

NAG Library Function Document nag_4d_shep_eval (e01tlc)

NAG Library Function Document nag_chain_sort (m01cuc)

NAG Toolbox for Matlab nag_rand_times_garch_exp (g05pg)

G07EAF NAG Fortran Library Routine Document

F04EBFP.1. NAG Parallel Library Routine Document

NAG Library Function Document nag_rngs_varma_time_series (g05pcc)

NAG Library Routine Document F08ASF (ZGEQRF).1

NAG C Library Function Document nag_rngs_varma_time_series (g05pcc)

Transcription:

NAG Library Routine Document 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 generates pseudorandom uniform bivariates with joint distribution of a Clayton/Cook Johnson Archimedean copula. 2 Specification SUBROUTINE (N, THETA, SORDER, STATE, X, LDX, SDX, IFAIL) INTEGER N, SORDER, STATE(*), LDX, SDX, IFAIL REAL (KIND=nag_wp) THETA, X(LDX,SDX) 3 Description Generates pseudorandom uniform bivariates fu 1 ;u 2 g 2 ð0; 1Š 2 whose joint distribution is the Clayton/ Cook Johnson Archimedean copula C with parameter, given by h i 1=, C ¼ max u 1 þ u 2 1; 0 2 ð 1; 1Þnfg 0 with the special cases: C 1 ¼ maxðu 1 þ u 2 1; 0Þ, the Fréchet Hoeffding lower bound; C 0 ¼ u 1 u 2, the product copula; C 1 ¼ minðu 1 ;u 2 Þ, the Fréchet Hoeffding upper bound. The generation method uses conditional sampling. 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. 4 References Nelsen R B (2006) An Introduction to Copulas (2nd Edition) Springer Series in Statistics 5 Parameters 1: N INTEGER Input On entry: n, the number of bivariates to generate. Constraint: N 0. 2: THETA REAL (KIND=nag_wp) Input On entry:, the copula parameter. Constraint: THETA 1:0..1

NAG Library Manual 3: SORDER INTEGER Input On entry: determines the storage order of variates; the ði; jþth variate is stored in Xði; jþ if SORDER ¼ 1, and Xðj; iþ if SORDER ¼ 2, for i ¼ 1; 2;...;n and j ¼ 1; 2. Constraint: SORDER ¼ 1or2. 4: STATEðÞ INTEGER array Communication 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. 5: XðLDX,SDXÞ REAL (KIND=nag_wp) array Output On exit: the n bivariate uniforms with joint distribution described by C, with Xði; jþ holding the ith value for the jth dimension if SORDER ¼ 1 and the jth value for the ith dimension of SORDER ¼ 2. 6: LDX INTEGER Input On entry: the first dimension of the array X as declared in the (sub)program from which is called. Constraints: if SORDER ¼ 1, LDX N; if SORDER ¼ 2, LDX 2. 7: SDX INTEGER Input On entry: the second dimension of the array X as declared in the (sub)program from which is called. Constraints: if SORDER ¼ 1, SDX 2; if SORDER ¼ 2, SDX N. 8: IFAIL INTEGER Input/Output On entry: IFAIL must be set to 0, 1 or 1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details. On exit: IFAIL ¼ 0 unless the routine detects an error or a warning has been flagged (see Section 6). For environments where it might be inappropriate to halt program execution when an error is detected, the value 1 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 1 or 1 is used it is essential to test the value of IFAIL on exit. 6 Error Indicators and Warnings If on entry IFAIL ¼ 0or 1, explanatory error messages are output on the current error message unit (as defined by X04AAF). Errors or warnings detected by the routine: IFAIL ¼ 1 On entry, STATE vector was not initialized or has been corrupted..2

IFAIL ¼ 2 On entry, THETA < 1:0. IFAIL ¼ 3 On entry, N < 0. IFAIL ¼ 4 On entry, SORDER 6¼ 1 and SORDER 6¼ 2. IFAIL ¼ 6 On entry, SORDER ¼ 1 and LDX < N, or SORDER ¼ 2 and LDX < 2. IFAIL ¼ 7 On entry, SORDER ¼ 1 and SDX < 2, or SORDER ¼ 2 and SDX < N. 7 Accuracy Not applicable. 8 Further Comments In practice, the need for numerical stability restricts the range of such that: if ð þ 1Þ <, the routine returns pseudorandom uniform variates with C 1 joint distribution; if jj< 1:0 10 6, the routine returns pseudorandom uniform variates with C 0 joint distribution; if >ln s = ln 1:0 10 2, the routine returns pseudorandom uniform variates with C1 joint distribution; where s is the safe-range parameter, the value of which is returned by X02AMF; and is the machine precision returned by X02AJF. 9 Example This example generates thirteen variates for copula C 0:8. 9.1 Program Text PROGRAM g05refe! Example Program Text! Release. NAG Copyright 2011.!.. Use Statements.. USE nag_library, ONLY : g05kff, g05ref, nag_wp, x04caf!.. Implicit None Statement.. IMPLICIT NONE!.. Parameters.. INTEGER, PARAMETER :: lseed = 1, nin = 5, nout = 6!.. Local Scalars.. REAL (KIND=nag_wp) :: theta INTEGER :: genid, ifail, ldx, lstate, n, sdx, & sorder, subid!.. Local Arrays.. REAL (KIND=nag_wp), ALLOCATABLE :: x(:,:) INTEGER :: seed(lseed).3

NAG Library Manual INTEGER, ALLOCATABLE :: state(:)!.. Executable Statements.. WRITE (nout,*) Example Program Results WRITE (nout,*) FLUSH (nout)! Skip heading in data file READ (nin,*)! Read in the base generator information and seed READ (nin,*) genid, subid, seed(1)! Initial call to initialiser to get size of STATE array lstate = 0 ALLOCATE (state(lstate)) CALL g05kff(genid,subid,seed,lseed,state,lstate,ifail)! Reallocate STATE DEALLOCATE (state) ALLOCATE (state(lstate))! Initialize the generator to a repeatable sequence CALL g05kff(genid,subid,seed,lseed,state,lstate,ifail)! Read in sample size and order READ (nin,*) n, sorder IF (sorder==1) THEN! X(N,2) ldx = n sdx = 2 ELSE! X(2,N) ldx = 2 sdx = n END IF ALLOCATE (x(ldx,sdx))! Read in parameter READ (nin,*) theta! Generate variates CALL g05ref(n,theta,sorder,state,x,ldx,sdx,ifail)! Display the variates IF (sorder==1) THEN! X(N,2) CALL x04caf( General,,n,2,x,ldx, & Uniform variates with copula joint distribution,ifail) ELSE! X(2,N) CALL x04caf( General,,2,n,x,ldx, & Uniform variates with copula joint distribution,ifail) END IF END PROGRAM g05refe 9.2 Program Data Example Program Data 1 1 1762543 :: GENID,SUBID,SEED(1) 13 1 :: N, SORDER -0.8 :: THETA.4

9.3 Program Results Example Program Results Uniform variates with copula joint distribution 1 2 1 0.6400 0.2223 2 0.1154 0.8101 3 0.7486 0.1439 4 0.8003 0.1062 5 0.1135 0.9946 6 0.4975 0.7655 7 0.3904 0.4925 8 0.7892 0.1196 9 0.5032 0.4116 10 0.6750 0.2093 11 0.0600 0.9055 12 0.2655 0.7085 13 0.6276 0.2370.5 (last)