50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

copBasic (version 2.2.7)

copBasic-package: Basic Theoretical Copula, Empirical Copula, and Various Utility Functions

Description

The copBasic package is oriented around bivariate copula theory and mathematical operations closely follow the recommended texts of Nelsen (2006) and Joe (2014) as well as select other references. Another recommended text is Salvadori et al. (2007) and Hofert et al. (2018) and are cited herein, but about half of that excellent book concerns univariate applications. The primal objective of copBasic is to provide a study of numerous results shown by authoritative texts on copulas. It is intended that the package will help other copula students in self study, potential course work, and applied circumstances.

Notes on copulas that are supported. The author has focused on pedagogical aspects of copulas, and this package is a diary of sorts beginning in fall 2008. Originally, the author did not implement many copulas in the copBasic in order to deliberately avoid redundancy to that support such as it exists on the R CRAN. Though as time has progressed, other copulas have been added occasionally based on needs of the user community, need to show some specific concept in the general theory, or test algorithms. For example, the Clayton copula (CLcop) was a late arriving addition the package (c.2017), which was added to assist a specific user; the Frank copula (FRcop was added in December 2024 because of an inquiry on using copBasic for vine copula (see vine example under FRcop).

The language and vocabulary of copulas are formidable even within the realm of bivariate or bicopula as design basis for the package. Often “vocabulary” words are often emphasized in italics, which is used extensively and usually near the opening of function-by-function documentation to identify vocabulary words, such as survival copula (see surCOP). This syntax tries to mimic and accentuate the terminology in Nelsen (2006), Joe (2014), and generally most other texts. Italics are used to draw connections between concepts.

In conjunction with the summary of functions in copBasic-package, the extensive cross referencing to functions and expansive keyword indexing should be beneficial. The author had no experience with copulas prior to a chance happening upon Nelsen (2006) in c.2008. The copBasic package is a personal tour de force in self-guided learning. Over time, this package and user's manual have been helpful to others.

Helpful Navigation of Copulas Implemented in the copBasic Package

Some entry points to the copulas implemented are listed in the Table of Copulas:

NameSymbolFunctionConcept
Lower-bounds copulaW(u,v)Wcopula
Independence copulaΠ(u,v)Pcopula
Upper-bounds copulaM(u,v)Mcopula
Fréchet Family copulaFF(u,v)FRECHETcopcopula
Ali--Mikhail--Haq copulaAMH(u,v)AMHcopcopula
Clayton copulaCL(u,v)CLcopcopula
Copula of uniform circleCIRC(u,v)CIRCcopcopula
Farlie--Gumbel--Morgenstern (generalized)FGM(u,v)FGMcopcopula
FrankFR(u,v)FRcopcopula
Galambos copulaGL(u,v)GLcopcopula
Gumbel--Hougaard copulaGH(u,v)GHcopcopula
Hüsler--Reiss copulaHR(u,v)HRcopcopula
Joe B5 (the “Joe”) copulaB5(u,v)JOcopB5copula
Nelsen eq.4-2-12 copulaN4212cop(u,v)N4212copcopula
Ordinal Sums by CopulaCJ(u,v)ORDSUMcopcopula
Pareto copulaPA(u,v)PLcopcopula
Plackett copulaPL(u,v)PLcopcopula
PSP copulaPSP(u,v)PSPcopula
Raftery copulaRF(u,v)RFcopcopula
Rayleigh copulaRAY(u,v)RAYcopcopula
g-EV copula (Gaussian extreme value)gEV(u,v)gEVcopcopula
t-EV copula (t-distribution extreme value)tEV(u,v)tEVcopcopula

A few comments on notation herein are needed. A bold math typeface is used to represent a copula function or family such as Π (see P) for the independence copula. The syntax R×RR2 denotes the orthogonal domain of two real numbers, and [0,1]×[0,1] I×II2 denotes the orthogonal domain on the unit square of probabilities. Limits of integration [0,1] or [0,1]2 involving copulas are thus shown as I and I2, respectively.

Random variables X and Y respectively denote the horizontal and vertical directions in R2. Their probabilistic counterparts are uniformly distributed random variables on [0,1], are respectively denoted as U and V, and necessarily also are the respective directions in I2 (U denotes the horizontal, V denotes the vertical). Often realizations of these random variables are respectively x and y for X and Y and u and v for U and V.

There is an obvious difference between nonexceedance probability F and its complement, which is exceedance probability defined as 1F. Both u and v herein are in nonexceedance probability. Arguments to many functions herein are u =u and v =v and are almost exclusively nonexceedance but there are instances for which the probability arguments are u =1u=u and v =1v=v.

Several of the functions listed above are measures of “bivariate association.” Two of the measures (Kendall Tau, tauCOP; Spearman Rho, rhoCOP) are widely known. R provides native support for their sample estimation of course, but each function can be used to call the cor() function in R for parallelism to the other measures of this package. The other measures (Blomqvist Beta, Gini Gamma, Hoeffding Phi, Schweizer--Wolff Sigma, Spearman Footrule) support sample estimation by specially formed calls to their respective functions: blomCOP, giniCOP, hoefCOP, wolfCOP, and footCOP. Gini Gamma (giniCOP) documentation (also joeskewCOP) shows extensive use of theoretical and sample computations for these and other functions.

Helpful Navigation of the copBasic Package

Some other entry points into the package are listed in the following table:

NameSymbolFunctionConcept
CopulaC(u,v)COPcopula theory
C(u,v)COP(..., reflect=*)reflection
C(u,v)COP(..., reflect=*)rotation
Survival copulaC^(u,v)surCOPcopula theory
Joint survival functionC(u,v)surfuncCOPcopula theory
Co-copulaC(u,v)coCOPcopula theory
Dual of a copulaC~(u,v)duCOPcopula theory
Primary copula diagonalδ(t)diagCOPcopula theory
Secondary copula diagonalδ(t)diagCOPcopula theory
Inverse copula diagonalδ(1)(f)diagCOPatfcopula theory
Joint probabilityjointCOPcopula theory
Bivariate L-momentsδk;C[]bilmoms and lcomCOPbivariate moments
Bivariate L-comomentsτk;C[]bilmoms and lcomCOPbivariate moments
Blomqvist BetaβCblomCOPbivariate association
Gini GammaγCginiCOPbivariate association
Hoeffding PhiΦChoefCOPbivariate association
Nu-SkewνCnuskewCOPbivariate moments
Nu-Star (skew)νCnustarCOPbivariate moments
Lp distance to independenceΦCLpLpCOPbivariate association
Permutation-MuμCpermsymLzCOPpermsympermutation asymmetry
Kendall TauτCtauCOPbivariate association
Kendall MeasureKC(z)kmeasCOPcopula theory
Kendall FunctionFK(z)kfuncCOPcopula theory
Inverse Kendall FunctionFK(1)(z)kfuncCOPinvcopula theory
An L-moment of FK(z)λr(FK)kfuncCOPlmomL-moment theory
L-moments of FK(z)λr(FK)kfuncCOPlmomsL-moment theory
Semi-correlations (negatives)ρN(a)semicorCOPbivariate tail association
Semi-correlations (positives)ρN+(a)semicorCOPbivariate tail association
Spearman FootruleψCfootCOPbivariate association
Spearman RhoρCrhoCOPbivariate association
Schweizer--Wolff SigmaσCwolfCOPbivariate association
Density of a copulac(u,v)densityCOPcopula density
Density visualizationdensityCOPplotcopula density
Empirical copulaCn(u,v)EMPIRcopcopula
Empirical simulationEMPIRsimcopula simulation
Empirical simulationEMPIRsimvcopula simulation
Empirical copulatic surfaceEMPIRgridcopulatic surface
Parametric copulatic surfacegridCOPcopulatic surface
Parametric simulationsimCOP or rCOPcopula simulation
Parametric simulationsimCOPmicrocopula simulation
Maximum likelihoodL(Θd)mleCOPcopula fitting
Akaike information criterionAICCaicCOPgoodness-of-fit
Bayesian information criterionBICCbicCOPgoodness-of-fit
Root mean square errorRMSECrmseCOPgoodness-of-fit
Another goodness-of-fitTnstatTngoodness-of-fit

Concerning goodness-of-fit and although not quite the same as copula properties (such as “correlation”) per se as the coefficients aforementioned in the prior paragraph, three goodness-of-fit metrics of a copula compared to the empirical copula, which are all based the mean square error (MSE), are aicCOP, bicCOP, and rmseCOP. This triad of functions is useful for making decisions on whether a copula is more favorable than another to a given dataset. However, because they are genetically related by using MSE and if these are used for copula fitting by minimization, the fits will be identical. A statement of “not quite the same” is made because the previously described copula properties are generally defined as types of deviations from other copulas (such as P). Another goodness-of-fit statistic is statTn, which is based on magnitude summation of fitted copula difference from the empirical copula. These four (aicCOP, bicCOP, rmseCOP, and statTn) collectively are relative simple and readily understood measures. These bulk sample statistics are useful, but generally thought to not capture the nuances of tail behavior (semicorCOP and taildepCOP might be useful).

Bivariate skewness measures are supported in the functions joeskewCOP (nuskewCOP and nustarCOP) and uvlmoms (uvskew). Extensive discussion and example computations of bivariate skewness are provided in the joeskewCOP documentation. Lastly, so-called bivariate L-moments and bivariate L-comoments of a copula are directly computable in bilmoms (though that function using Monte Carlo integration is deprecated) and lcomCOP (direct numerical integration). The lcomCOP function is the theoretical counterpart to the sample L-comoments provided in the lmomco package.

Bivariate random simulation methods by several functions are identified in the previous table. The copBasic package explicitly uses only conditional simulation also known as the conditional distribution method for random variate generation following Nelsen (2006, pp. 40--41) (see also simCOPmicro, simCOP). The numerical derivatives (derCOP and derCOP2) and their inversions (derCOPinv and derCOPinv2) represent the foundation of the conditional simulation. There are other methods in the literature and available in other R packages, and a comparison of some methods is made in the Examples section of the Gumbel--Hougaard copula (GHcop).

Several functions in copBasic make the distinction between V with respect to (wrt) U and U wrt V, and a guide for the nomenclature involving wrt distinctions is listed in the following table:

NameSymbolFunctionConcept
Copula inversionV wrt UCOPinvcopula operator
Copula inversionU wrt VCOPinv2copula operator
Copula derivativeδC/δuderCOPcopula operator
Copula derivativeδC/δvderCOP2copula operator
Copula derivative inversionV wrt UderCOPinvcopula operator
Copula derivative inversionU wrt VderCOPinv2copula operator
Joint curvestC(u=U,v)joint.curvesCOPcopula theory
Joint curvestC(u,v=V)joint.curvesCOP2copula theory
Level curvestC(u=U,v)level.curvesCOPcopula theory
Level curvestC(u,v=V)level.curvesCOP2copula theory
Level setV wrt Ulevel.setCOPcopula theory
Level setU wrt Vlevel.setCOP2copula theory
Median regressionV wrt Umed.regressCOPcopula theory
Median regressionU wrt Vmed.regressCOP2copula theory
Quantile regressionV wrt Uqua.regressCOPcopula theory
Quantile regressionU wrt Vqua.regressCOP2copula theory
Copula sectiontC(t,a)sectionCOPcopula theory
Copula sectiontC(a,t)sectionCOPcopula theory

The previous two tables do not include all of the myriad of special functions to support similar operations on empirical copulas. All empirical copula operators and utilities are prepended with EMPIR in the function name. An additional note concerning package nomenclature is that an appended “2” to a function name indicates U wrt V (e.g. EMPIRgridderinv2 for an inversion of the partial derivatives δC/δv across the grid of the empirical copula).

Some additional functions to compute often salient features or characteristics of copulas or bivariate data, including functions for bivariate inference or goodness-of-fit, are listed in the following table:

NameSymbolFunctionConcept
Left-tail decreasingV wrt UisCOP.LTDbivariate association
Left-tail decreasingU wrt VisCOP.LTDbivariate association
Right-tail increasingV wrt UisCOP.RTIbivariate association
Right-tail increasingU wrt VisCOP.RTIbivariate association
Pseudo-polar representation(S^,W^)psepolarextremal dependency
Tail concentration functionqC(t)tailconCOPbivariate tail association
Tail (lower) dependencyλCLtaildepCOPbivariate tail association
Tail (upper) dependencyλCUtaildepCOPbivariate tail association
Tail (lower) orderκCLtailordCOPbivariate tail association
Tail (upper) orderκCUtailordCOPbivariate tail association
Neg'ly quadrant dependencyNQDisCOP.PQDbivariate association
Pos'ly quadrant dependencyPQDisCOP.PQDbivariate association
Permutation symmetrypermsymisCOP.permsymcopula symmetry
Radial symmetryradsymisCOP.radsymcopula symmetry
Skewness (Joe, 2014)η(p;ψ)uvskewbivariate skewness
Kullback--Leibler DivergenceKL(fg)kullCOPbivariate inference
KL sample sizenfgkullCOPbivariate inference
The Vuong ProcedurevuongCOPbivariate inference
Spectral measureH(w)spectralmeasextremal dependency inference
Stable tail dependencel^(x,y)stabtaildepfextremal dependency inference
L-comoments (samp. distr.)lcomCOPpvexperimental bivariate inference

The Table of Probabilities that follows lists important relations between various joint probability concepts, the copula, nonexceedance probabilities u and v, and exceedance probabilities u and v. A compact summary of these probability relations has obvious usefulness. The notation [,] is to read as [ and ], and the [] is to be read as [ given ].

ProbabilityandSymbol Convention
Pr[Uu,Vv]=C(u,v) --- The copula, COP
Pr[U>u,V>v]=C^(u,v) --- The survival copula, surCOP
Pr[Uu,V>v]=uC(u,v)
Pr[U>u,Vv]=vC(u,v)
Pr[UuVv]=C(u,v)/v
Pr[VvUu]=C(u,v)/u
Pr[UuV>v]=(uC(u,v))/(1v)
Pr[VvU>u]=(vC(u,v))/(1u)
Pr[U>uV>v]=C^(u,v)/u=C(u,v)/(1u)
Pr[V>vU>u]=C^(u,v)/v=C(u,v)/(1v)
Pr[VvU=u]=δC(u,v)/δu --- Partial derivative, derCOP
Pr[UuV=v]=δC(u,v)/δv --- Partial derivative, derCOP2
Pr[U>u or V>v]=C(u,v)=1C(u,v) --- The co-copula, coCOP
Pr[Uu or Vv]=C~(u,v)=u+vC(u,v) --- The dual of a copula, duCOP
E[UV=v]=01(1δC(u,v)/δv)du --- Expectation of U given V, EuvCOP
E[VU=u]=01(1δC(u,v)/δu)dv --- Expectation of V given U, EvuCOP

The function jointCOP has considerable demonstration in its Note section of the joint and and joint or relations shown through simulation and counting scenarios. Also there is a demonstration in the Note section of function duCOP on application of the concepts of joint and conditions, joint or conditions, and importantly joint mutually exclusive or conditions.

Copula Construction Methods

Permutation asymmetry can be added to a copula by breveCOP. One, two, or more copulas can be “composited,” “combined,” or “multiplied” in interesting ways to create highly unique bivariate relations and as a result, complex dependence structures can be formed. The package provides three main functions for copula composition: composite1COP composites a single copula with two compositing parameters (Khoudraji device with independence), composite2COP (Khoudraji device) composites two copulas with two compositing parameters, and composite3COP composites two copulas with four compositing parameters. Also two copulas can be combined through a weighted convex combination using convex2COP with a single weighting parameter, and even N number of copulas can be combined by weights using convexCOP. So-called “gluing” two copula by a parameter is provided by glueCOP. Multiplication of two copulas to form a third is supported by prod2COP. All eight functions for compositing, combining, or multipling copulas are compatible with joint probability simulation (simCOP), measures of association (e.g. ρC), and presumably all other copula operations using copBasic features. Finally, ordinal sums of copula are provided by ORDSUMcop and ORDSUWcop as particularly interesting methods of combining copulas.

No. of copulasCombining ParametersFunctionConcept
1βbreveCOPadding permuation asymmetry
1α,βcomposite1COPcopula combination
1α,βkhoudraji1COPcopula combination
1α,βkhoudrajiPCOPcopula combination
2α,βcomposite2COPcopula combination
2α,βkhoudraji2COPcopula combination
2α,β,κ,γcomposite3COPcopula combination
2α,(1α)convex2COPweighted copula combination
NωiNconvexCOPweighted copula combination
2γglueCOPgluing of coupla
2(C1C2)prod2COPcopula multiplication
NCJi for JiN partitionsORDSUMcopM-ordinal sums of copulas
NCJi for JiN partitionsORDSUWcopW-ordinal sums of copulas

Useful Copula Relations by Visualization

There are a myriad of relations amongst variables computable through copulas, and these were listed in the Table of Probabilities earlier in this documentation. There is a script located in the inst/doc directory of the copBasic sources titled CopulaRelations_BaseFigure_inR.txt. This script demonstrates, using the PSP copula, relations between the copula (COP), survival copula (surCOP), joint survival function of a copula (surfuncCOP), co-copula (coCOP), and dual of a copula function (duCOP). The script performs simulation and manual counts observations meeting various criteria in order to compute their empirical probabilities. The script produces a base figure, which after extending in editing software, is suitable for educational description and is provided at the end of this documentation.

A Review of “Return Periods” using Copulas

Risk analyses of natural hazards are commonly expressed as annual return periods T in years, which are defined for a nonexceedance probability q as T=1/(1q). In bivariate analysis, there immediately emerge two types of return periods representing Tq;coop and Tq;dual conditions between nonexceedances of the two hazard sources (random variables) U and V. It is usual in many applications for T to be expressed equivalently as a probability q in common for both variables.

Incidentally, the Pr[U>uV>v] and Pr[V>vU>u] probabilities also are useful for conditional return period computations following Salvadori et al. (2007, pp. 159--160) but are not further considered here. Also the FK(w) (Kendall Function or Kendall Measure of a copula) is the core tool for secondary return period computations (see kfuncCOP).

Let the copula C(u,v;Θ) for nonexceedances u and v be set for some copula family (formula) by a parameter vector Θ. The copula family and parameters define the joint coupling (loosely meant the dependency/correlation) between hazards U and V. If “failure” occurs if either or both hazards U and V are at probability q threshold (u=v=11/T=q) for T-year return period, then the real return period of failure is defined using either the copula C(q,q;Θ) or the co-copula C(q,q;Θ) for exceedance probability q=1q is

Tq;coop=11C(q,q;Θ)=1C(1q,1q;Θ)\ and Tq;coop1cooperative risk.

Or in words, the hazard sources collaborate or cooperate to cause failure. If failure occurs, however, if and only if both hazards U and V occur simultaneously (the hazards must “dually work together” or be “conjunctive”), then the real return period is defined using either the dual of a copula (function) C~(q,q;Θ), the joint survival function C(q,q;Θ), or survival copula C^(q,q;Θ) as

Tq;dual=11C~(q,q;Θ)=1C(q,q;Θ)=1C^(q,q;Θ)\ and Tq;dual1complement of dual protection.

Numerical demonstration is informative. Salvadori et al. (2007, p. 151) show for a Gumbel--Hougaard copula (GHcop) having Θ= 3.055 and T= 1,000 years (q=0.999) that Tq;coop=797.1 years and that Tq;dual = 1,341.4 years, which means that average return periods between “failures” are Tq;coopTTq;dual\ and thus 797.1T1314.4\ years.

With the following code, these bounding return-period values are readily computed and verified using the prob2T() function from the lmomco package along with copBasic functions COP (generic functional interface to a copula) and duCOP (dual of a copula):


  q <- lmomco::T2prob(1000)
  lmomco::prob2T(  COP(q,q, cop=GHcop, para=3.055)) #  797.110
  lmomco::prob2T(duCOP(q,q, cop=GHcop, para=3.055)) # 1341.438

An early source (in 2005) by some of those authors cited on p. 151 of Salvadori et al. (2007; their citation “[67]”) shows Tq;dual=798 years---a rounding error seems to have been committed. Finally just for reference, a Gumbel--Hougaard copula having Θ=3.055 corresponds to an analytical Kendall Tau (see GHcop) of τ0.673, which can be verified through numerical integration available from tauCOP as:


  tauCOP(cop=GHcop, para=3.055, brute=TRUE) # 0.6726542

Thus, a “better understanding of the statistical characteristics of [multiple hazard sources] requires the study of their joint distribution” (Salvadori et al., 2007, p. 150).

Interaction of copBasic to Copulas in Other Packages

Originally, the copBasic package was not intended to be a port of the numerous bivariate copulas or over re-implementation other bivariate copulas available in R though as the package passed its 10th year in 2018, the original intent changed. It is useful to point out a demonstration showing an implementation of the Gaussian copula from the copula package, which is shown in the Note section of med.regressCOP in a circumstance of ordinary least squares linear regression compared to median regression of a copula as well as prediction limits of both regressions. Another demonstration in context of maximum pseudo-log-likelihood estimation of copula parameters is seen in the Note section mleCOP, and also see “API to the copula package” or “package copula (comparison to)” entries in the Index of this user manual.

Arguments

Author

William Asquith william.asquith@ttu.edu

References

Cherubini, U., Luciano, E., and Vecchiato, W., 2004, Copula methods in finance: Hoboken, NJ, Wiley, 293 p.

Hernández-Maldonado, V., Díaz-Viera, M., and Erdely, A., 2012, A joint stochastic simulation method using the Bernstein copula as a flexible tool for modeling nonlinear dependence structures between petrophysical properties: Journal of Petroleum Science and Engineering, v. 90--91, pp. 112--123.

Joe, H., 2014, Dependence modeling with copulas: Boca Raton, CRC Press, 462 p.

Hofert, M., Kojadinovic, I., Mächler, M., and Yan, J., 2018, Elements of copula modeling with R: Dordrecht, Netherlands, Springer.

Nelsen, R.B., 2006, An introduction to copulas: New York, Springer, 269 p.

Salvadori, G., De Michele, C., Kottegoda, N.T., and Rosso, R., 2007, Extremes in nature---An approach using copulas: Dordrecht, Netherlands, Springer, Water Science and Technology Library 56, 292 p.