Search code examples
rderivative

Copula-based conditional probability


Reading the paper "A multivariate model of sea storms using copulas" (De Michele et al., 2007) https://www.sciencedirect.com/science/article/pii/S0378383907000592 I'm stuck on partial derivatives' calculation in R.

The mathematical background:

If you have three variables H, D, I (with U1=F(H) etc.) and you need to estimate the conditional probability

P(U3|U1,U2)

you should first estimate the ratio of partial derivatives such as

(∂C(u1,u2,u3)/∂u1 ∂u2) / (∂C(u1,u2)/∂u1 ∂u2)

(for more details, please see the image),According to De Michele et al., 2007

The code:

Following the R package "VineCopula" (https://cran.r-project.org/web/packages/VineCopula/VineCopula.pdf) the function dduCopula evaluates the partial derivative

∂C(u1,u2)/∂u1,

so this procedure is easy for the simple partial derivatives (named k, m and n in the image).

But how can I estimate the partial derivative which is in respect of another variable "u1" compared to the copula C(k,m).

∂C(k,m)/∂u1 ?

For the partial derivatives k and n:

library(VineCopula)
u1<-pobs(H)
u2<-pobs(D) 
library(copula)
C_hd <- BB1Copula()
k <- ddvCopula(cbind(u1,u2), C_hd)
n <- dduCopula(cbind(u1,u2), C_hd)

Do you have any idea?


Solution

  • The construction principle proposed by De Michele et al. (2017) in the trivariate case is widely known as vine copula or pair-copula construction. If you want to work with such models, I suggest to read a bit more about them first. A good starting point is the paper of Aas et al. (2009) and you will find many more on http://www.vine-copula.org or google scholar.

    Now to your question: By the chain rule, we obtain this and, hence, that .

    An example in R is:

    # required package
    library(VineCopula)
    
    ## simulate data
    H <- rnorm(100)
    D <- rnorm(100)
    I <- rnorm(100)
    
    ## probability integral transforms
    u_H <- pobs(H)
    u_D <- pobs(D) 
    u_I <- pobs(I)
    
    ## define dummy pair-copulas
    C_HD <- BB1Copula()
    C_DI <- BB1Copula()
    C_HIgivenD <- BB1Copula()  # this is conditional dependence!
    
    ## calculate the conditional probability
    k <- ddvCopula(cbind(u_H, u_D), C_HD)
    m <- dduCopula(cbind(u_D, u_I), C_DI)
    cond_prob <- dduCopula(cbind(k, m), C_HIgivenD)