Nested Archimedean Copulas Meet R — The nacopula Package

The package copula (formerly nacopula ) provides procedures for constructing nested Archimedean copulas in any dimensions and with any kind of nesting structure, generating vectors of random variates from the constructed objects, computing function values and probabilities of falling into hypercubes, as well as evaluation of characteristics such as Kendall’s tau and the tail-dependence coeﬃcients. As by-products, algorithms for various distributions, including exponentially tilted stable and Sibuya distributions, are implemented. Detailed examples are given.


Introduction 1
A copula is a multivariate distribution function with standard uniform univariate margins.Standard references for an introduction are Joe (1997) or Nelsen (2007).Sklar (1959) shows that for any multivariate distribution function H with margins F j , j ∈ {1, . . ., d}, there exists a copula C such that H(x 1 , . . ., x d ) = C(F 1 (x 1 ), . . ., F d (x d )), x ∈ R d . (1) Conversely, given a copula C and arbitrary univariate distribution functions F j , j ∈ {1, . . ., d}, H defined by ( 1) is a distribution function with marginals F j , j ∈ {1, . . ., d}.On one hand, Sklar's Theorem tells us that we can decompose any given multivariate distribution function into its margins and a copula.By this decomposition, copulas allow us to study multivariate distributions functions independently of the margins.This is of particular interest in statistics.On the other hand, Sklar's Theorem provides a tool for constructing large classes of multivariate distributions and is therefore often used for sampling multivariate distributions via copulas.This is indispensable for many applications in the areas of statistics and finance.
For sampling the multivariate distribution H it suffices to sample the common dependence structure, given by the copula C, and to transform the obtained variates to the correct margins F j , j ∈ {1, . . ., d}.Since this transformation is usually easy to achieve (simply apply the generalized inverse F − j (y) = inf{x ∈ R : F j (x) ≥ y} corresponding to F j , j ∈ {1, . . ., d}, with the convention that inf ∅ = ∞), sampling from H usually boils down to sampling the copula C under consideration.
Alongside elliptical copulas, i.e., the copulas arising from elliptical distributions via Sklar's Theorem (see, e.g., Embrechts, Lindskog, and McNeil (2003)), Archimedean copulas play an important role in practical applications.In contrast to elliptical ones, Archimedean copulas are given explicitly in terms of a generator.They are able to capture different kinds of tail dependencies, e.g., only upper tail dependence and no lower tail dependence or both lower and upper tail dependence but of different magnitude.With the algorithm of Marshall and Olkin (1988), Archimedean copulas are usually easy to sample.Their functional symmetry (in u j , j = 1, . . ., d), also referred to as exchangeability, however, is often considered to be a drawback, e.g., in risk-management applications where the considered portfolios are typically high-dimensional.To circumvent exchangeability, Archimedean copulas can be nested within each other under certain conditions.The resulting copulas are referred to as "nested Archimedean copulas" and allow to model hierarchical dependence structures.
The R package copula (formerly nacopula) implements several functions for working with Archimedean and nested Archimedean copulas.In contrast to other R packages dealing with Archimedean copulas, e.g., copula (Yan (2007); Kojadinovic and Yan (2010)) or fCopulae (Wuertz et al. (2009)), particular focus is put on nested Archimedean copulas.The R package nacopula had been the first R package dealing with these functions, and is now part of the R package copula.It is available from the Comprehensive R Archive Network at https: //CRAN.R-project.org/package=copula.
Note that the distribution function F is known for virtually all commonly used Archimedean generators, see, e.g., Hofert (2010, p. 62).The package copula currently provides the most widely used families of Ali-Mikhail-Haq, Clayton, Frank, Gumbel, and Joe; see Table 1 for the generators and their corresponding distribution functions.Except for Clayton's family, where we use a slightly simpler generator, these generators are the ones given in Nelsen (2007, pp. 116).Also note that for the families of Ali-Mikhail-Haq, Frank, and Joe, F is discrete with support N. In this case, ψ is of the form ψ(t) = ∞ k=1 p k exp(−kt), t ∈ [0, ∞], where (p k ) ∞ k=1 denotes the probability mass function corresponding to F .These Archimedean copula families are provided as "acopula" R objects (for more information about the statistical software R, see R Development Core Team (2010, 2.11.1)), containing as slots the corresponding generator ψ, psi, its inverse ψ −1 , iPsi, and the "sampler", i.e., random number generator for V ∼ F , as V0: R> require(copula) R> ls("package:copula", pattern = "^cop[A-Z]") [1] "copAMH" "copClayton" "copFrank" "copGumbel" "copJoe"

Sampling Archimedean copulas
From a mixture representation with respect to F , the following algorithm may be derived for sampling Archimedean copulas, see Marshall and Olkin (1988).

Family
Parameter Table 1: Commonly used one-parameter Archimedean generators.

The rank-correlation coefficient Kendall's tau
In practical applications, it is often desirable to measure the degree of dependence between random variables by a real number, a generalized correlation.Such measures are referred to as measures of association and are usually studied for in the bivariate case, i.e., for pairs of random variables.One such measure is Kendall's tau.For a bivariate vector of continuously distributed random variables (X 1 , X 2 ) T , Kendall's tau is defined by T is an independent and identically distributed copy of (X 1 , X 2 ) T and sign(x) = 1 (0,∞) (x) − 1 (−∞,0) (x) denotes the signum function (as R's sign(x)).Since Kendall's tau equals the probability of concordance minus the probability of discordance, it is a measure of concordance, see, e.g., Scarsini (1984).Informally, it measures, as a number in [−1, 1], the probability with which large values of one variable are associated with large values of the other.If C is a bivariate Archimedean copula generated by a twice continuously differentiable generator ψ with ψ(t) > 0, t ∈ [0, ∞), Kendall's tau can be represented in semi-closed form as see Joe (1997, p. 91).For the Archimedean families of Ali-Mikhail-Haq, Clayton, and Gumbel, this integral can be evaluated explicitly, for Frank's family it involves the Debye function of order one, i.e., D 1 (θ) = 1 θ θ 0 t/(e t − 1) dt, and for Joe's family, it is given as a series, see Table 2.

Tail-dependence coefficients
Another notion of association is tail dependence.Tail dependence measures the probability that one random variable takes on values in its tail, given the other one takes on values in its tail.To be more precise, if X j ∼ F j , j ∈ {1, 2}, are continuously distributed random variables, the lower tail-dependence coefficient, respectively the upper tail-dependence coefficient, of X 1 and X 2 are defined as provided that the limits exist.These measures of association can be expressed in terms of the copula C corresponding to (X 1 , X 2 ) T .If C is a bivariate Archimedean copula generated by ψ with ψ(t) > 0, t ∈ [0, ∞), then where the equalities involving derivatives are obtained by l'Hôpital's rule and therefore the corresponding assumptions are required to hold.For the implemented Archimedean families, these limits can easily be found and are given in Table 2.

A three-dimensional Joe copula
As an example, we define a three-dimensional Joe copula with parameter chosen such that Kendall's tau (for the corresponding bivariate marginal copula of the Archimedean type) equals 0.5; this is achieved with the function iTau, which computes the parameter θ such that Kendall's tau equals 0.5.

Construction
In contrast to elliptical copulas, Archimedean copulas can capture different tail dependencies, i.e., λ l ̸ = λ u .Further, they are given explicitly, which facilitates computing probabilities for such dependence models.However, the exchangeability inherent in Archimedean copulas implies that all margins of the same dimension are equal.For modeling purposes, this becomes an increasingly strong assumption in the dimension.Asymmetries, i.e., more realistic dependencies, can be modeled by a hierarchical structure of Archimedean copulas, obtained by plugging in Archimedean copulas into each other.In practical applications, these hierarchical structures are often naturally motivated, e.g., by different macroeconomic effects, political decisions, or consumer trends affecting the components of a random vector.
A d-dimensional copula C is called nested Archimedean if it is an Archimedean copula with arguments possibly replaced by other nested Archimedean copulas.If C is given recursively by (2) for d = 2 and, up to permutation of the arguments, for d ≥ 3, by then C is called fully nested Archimedean copula with d−1 nesting levels or hierarchies.Otherwise, C is called partially nested Archimedean copula.Fully and partially nested Archimedean copulas are summarized as nested (or hierarchical) Archimedean copulas.
Note that the structure of a nested Archimedean copula can be depicted by a tree.For example, the three-dimensional nested Archimedean copula of Type (4) involving the generators ψ 0 and ψ 1 , which is given by can be depicted by the tree structure as given in Figure 2. Due to this tree representation, Figure 2: Tree structure of a three-dimensional fully nested Archimedean copula.
we refer to the outermost Archimedean copula (generated by ψ 0 ) as root copula.Further, we call an Archimedean copula parent copula if it has at least one nested Archimedean copula as one of its components in the tree structure of a nested Archimedean copula.We refer to these components as child copulas.For example, the three-dimensional nested Archimedean copula as given in Figure 2 has parent copula C(• ; ψ 0 ) (which is also the root copula here) with child copula C(• ; ψ 1 ); as another example, C(• ; ψ 1 ) in Figure 3 is the parent copula of the child copula C(• ; ψ 2 ) and C(• ; ψ 0 ) is the parent of C(• ; ψ 1 ).
In R, because of the recursive tree structure, a powerful approach is to use a recursive class definition: In the copula package, we define the nacopula (nested archimedean copula) class, with three components (slots), i.e., by its root copula (slot @copula, an "acopula" object), a vector of indices of its "direct components" (slot @comp = 1 for u 1 in the example), and a list of child copulas (slot @childCops).The childCops list is the tool to contain sub branches of the "tree" of nested copulas, and will be empty, i.e., list(), for the final nodes (referred to as leaves) of the tree.
In the example, it will be of length one, containing a (non-nested) bivariate copula for the components u 2 and u 3 .
The class outer_nacopula is a version of the same class (i.e., it "contains" nacopula without any further slots), just with stricter validity checking, namely requiring that all components from all child copulas are exactly the set {1, 2, . . ., d}.
R> stopifnot (identical(C3, + onacopula("A", C(0.2, 1, list(C(0.8, 2:3, list The recursive definition (4) of nested Archimedean copulas not only leads to recursive class definitions in R, but also to recursive functions for computations involving such "nacopulas".All the following functions and methods (from our package copula) are defined recursively, typically using lapply(x@childCops, <fun>): The utilities dim(), allComp(), printNacopula() (which is the hidden show() method), and the principal functions pnacopula() and rncopula() (via recursive utility rnchild()).As a simple example of these, pnacopula(x, u) simply evaluates the (recursive) Formula (4), recursively applying itself to its child copulas: (sum(unlist(lapply(u[x@comp], C@iPsi, theta=th)), C@iPsi(unlist(lapply(x@childCops, pnacopula, u = u)), theta=th)), theta=th) } In order for (4) to be indeed a proper copula, Joe (1997, p. 88) andMcNeil (2008) present the sufficient nesting condition that ψ −1 i • ψ j is completely monotone for all nodes (with parent i and child j) appearing in a nested Archimedean copula.This condition can be derived from a mixture representation of C based on the distribution functions F 0 = LS −1 [ψ 0 ] and The sufficient nesting condition is often easily verified if all generators appearing in the nested structure come from the same parametric family.For each of the implemented Archimedean families of Ali-Mikhail-Haq, Clayton, Frank, Gumbel, and Joe, two generators ψ i , ψ j of the same family with corresponding parameters θ i , θ j , respectively, fulfill the sufficient nesting condition if θ i ≤ θ j ; equivalently, if τ i ≤ τ j for the corresponding Kendall's tau.Verifying the sufficient nesting condition if ψ i and ψ j belong to different Archimedean families is usually more complicated, see, Hofert (2010).Such combinations of Archimedean families are therefore currently not implemented in the R package copula.

Sampling
If the sufficient nesting condition is fulfilled for all nodes in the nested Archimedean structure, the following algorithm, based on proposals by McNeil (2008) and Hofert (2011), may be derived for sampling nested Archimedean copulas.

Algorithm 3.1
Let C be a nested Archimedean copula with root copula C 0 generated by ψ 0 .Let U be a vector of the same dimension as C. ( (2) for all components u of C 0 that are nested Archimedean copulas do { (3) set C 1 with generator ψ 1 to the nested Archimedean copula u (4) Note that for sampling nested Archimedean copulas when all generators involved belong to the same parametric family, it suffices to know how to sample as all distribution functions F ij take the same form as F 01 , only the parameters may differ.In our R package copula (formerly nacopula), the supported Archimedean family objects therefore provide the three slots V0, nestConstr, and V01, all functions.nestConstr, is a function(θ 0 , θ 1 ) which returns TRUE if the sufficient nesting condition is fulfilled and V0 and V01 are random number generating functions, generating V from Table 1 and V  Sampling strategies for F 0 and F 01 for many known Archimedean generators are presented in Hofert (2008), Hofert (2010), andHofert (2011).For the families of Ali-Mikhail-Haq, Clayton, Frank, Gumbel, and Joe, Table 3 summarizes stochastic representations for V 0 and V 01 .

Family
Nesting Table 3: Sufficient nesting conditions and stochastic representations for V 01 .
First note that for nested Archimedean copulas based on generators belonging to the same Archimedean family, all implemented families indeed lead to proper copulas if the generators on a more nested (inner) level have larger parameter values than the ones on a lower (outer) level.This is equivalent to saying that Kendall's tau for a pair of random variables having a bivariate Archimedean copula which resides on a deeper nesting level as margin has to be larger than or equal to the one for a pair of random variables having an Archimedean marginal copula residing on a lower nesting level.Slightly more informally, the inner (or lower) nested components u j are more correlated than the outer ("higher up") ones.
Some comments on the distributions F 01 of V 01 for the different implemented families: For the family of Ali-Mikhail-Haq, V 01 admits the stochastic representation V 0 + X, where X follows a negative binomial distribution with parameters as given in Table 3.The parameterization is NB(r, p), r ∈ (0, ∞), p ∈ (0, 1), with mass function For Clayton's family, F 01 can be interpreted as a special case (take h = 1, α = θ 0 /θ 1 ) of the exponentially tilted stable distribution S(α, 1, (cos(απ/2)V 0 ) 1/α , V 0 1 {α=1} , h1 {α̸ =1} ; 1) (5) with α ∈ (0, 1], h ∈ [0, ∞), V 0 ∈ (0, ∞), and corresponding Laplace-Stieltjes transform Hofert (2011) suggested a fast rejection algorithm for sampling this distribution.Devroye (2009) suggested an algorithm for sampling the exponentially tilted stable distribution with α ∈ (0, 1], λ ∈ [0, ∞), and corresponding Laplace-Stieltjes transform One can easily check that by setting λ = hV 1/α 0 and generating V λ with the algorithm of Devroye (2009), the random variable V 01 from F 01 as given by ( 5) can be obtained via Therefore, the distribution as given in (5) may be sampled by either the algorithm of Devroye (2009) or the one of Hofert (2011).The former author reports that the complexity of his algorithm is bounded, the latter author shows that the complexity of his algorithm is O(V 0 h α ).We implemented both algorithms for sampling (5) in the package nacopula (now copula) and decide for each drawn V 0 which method is to be applied.As a simple rule, investigated by several parameter combinations, the default chooses the method of Hofert (2011) if V 0 h α < 4 and the one of Devroye (2009) otherwise.As mentioned before, note that for sampling nested Clayton copulas, we have h = 1.Further, E[V 0 ] = 1/θ 0 .Hence, in the mean, the algorithm of Hofert (2011) is more often applied if θ 0 > 1/4, equivalently, if Kendall's tau for the bivariate Archimedean copula generated by ψ 0 is greater than 1/9.
For the family of Gumbel, ψ 01 (t; V 0 ) = exp(−V 0 t α ), α = θ 0 /θ 1 , hence, see Table 1, F 01 corresponds to the stable distribution as given in Table 3.For Joe's family, V 01 can be represented as a V 0 -fold sum of independent and identically Sibuya distributed random variables V k , k ∈ {1, . . ., V 0 }, which can be sampled with the R function rSibuya(., α) we provide.For large V 0 an approximation based on a stable distribution may be used, see Hofert (2011).Finally, Frank's family is more complicated.We refer to the source code of the package copula and references therein for more details.

Conclusion
The package copula (formerly nacopula) allows us to easily construct and work with nested Archimedean copulas.First and foremost, fast sampling algorithms for these copulas are implemented.As a by-product, the package also provides related mathematical and random number generating functions, e.g., efficient sampling algorithms for exponentially tilted stable and Sibuya distributions.Further features include the evaluation of nested Archimedean copulas, as well as computing probabilities of a random vector falling into a given hypercube.Concerning measures of association, Kendall's tau and the tail-dependence coefficients are implemented.Currently supported Archimedean families include the well-known families of Ali-Mikhail-Haq, Clayton, Frank, Gumbel, and Joe.Each can be used in generalized form via "outer power" transformations.

Figure 4 :
Figure 4: 500 vectors of random variates following a nine-dimensional nested Clayton copula with three different levels of dependence.

Figure 5 :
Figure 5: 500 vectors of random variates following a trivariate nested outer power Clayton copula.

Table 2 :
Kendall's tau and tail-dependence coefficients for commonly used one-parameter Archimedean generators.