# D1: Calculate the D1 distance between two dependence structures In qad: Quantification of Asymmetric Dependence

 D1 R Documentation

## Calculate the D1 distance between two dependence structures

### Description

Computation of the D1 distance between two checkerboard copulas A and B, corresponding to the random vectors (X1,Y1) and (X2,Y2), respectively. The function `D1()` computes the difference between the dependence structures of two random vectors. The function `D1.ECBC()` computes the D1-distance between two checkerboard copulas with the same resolution. The function `zeta1()` is defined as 3D1(A,Pi), where Pi denotes the independence copula and returns the dependence measure computed in qad.

### Usage

```D1(x1, y1, x2, y2, resolution = NULL)

D1.ECBC(A, B)

zeta1(X, Y, resolution = NULL)
```

### Arguments

 `x1` a (non-empty) numeric vector of data values for the first random vector (first coordinate) `y1` a (non-empty) numeric vector of data values for the first random vector (second coordinate) `x2` a (non-empty) numeric vector of data values for the second random vector (first coordinate) `y2` a (non-empty) numeric vector of data values for the second random vector (second coordinate) `resolution` integer indicating the resolution of the checkerboard copula. (default = NULL) `A` Numeric matrix of dimension NxN indicating the mass of the first N-checkerboad copula `B` Numeric matrix of dimension NxN indicating the mass of the second N-checkerboad copula `X` Numeric vector of values in the first coordinate `Y` Numeric vector of values in the second coordinate

### Value

`D1()` returns the D1 distance, introduced in (Trutschnig, 2011).

`D1.ECBC()` returns the D1-distance between to checkerboard copulas A and B with same resolution

`zeta1()` returns the directed dependence from x to y.

### References

Trutschnig, W. (2011). On a strong metric on the space of copulas and its induced dependence measure. Journal of Mathematical Analysis and Applications. 384 (2), 690-705.

Junker, R.R., Griessenberger, F. and Trutschnig, W. (2021). Estimating scale-invariant directed dependence of bivariate distributions. Computational Statistics and Data Analysis, 153, 107058.

### Examples

```
n <- 100
x1 <- runif(n)
y1 <- x1
x2 <- runif(n)
y2 <- 1-x2
D1(x1,y1,x2,y2)

n <- 1000
x <- runif(n, 0, 1)
y1 <- ifelse(x < 0.5, runif(length(x < 0.5), 0,0.5), runif(length(x >= 0.5), 0.5, 1))
y2 <- ifelse(x > 0.5, runif(length(x < 0.5), 0,0.5), runif(length(x >= 0.5), 0.5, 1))
A <- ECBC(x,y1, resolution = 50)
B <- ECBC(x,y2, resolution = 50)
#plot_density(A)
#plot_density(B)
D1.ECBC(A,B)
```

qad documentation built on Dec. 28, 2022, 2:54 a.m.