Search code examples
rprobability

Probability distribution from Clayton Copula in R


I have a Clayton Copula with variables X and Y and I want to get the joint and conditional probabilities P(X≤x, Y≤y) and P(X≤x|Y≤y). For example the probability that X is below its 1st percentile conditional on Y being below its first percentile: P(X≤1%|Y≤1%)

I have tried using R prob() function but I am unsure about the output.

library(VineCopula)
   library(copula)
#I estimate my Copula and assumes normal distribution for the two marginals
copula_dist <- mvdc(copula=claytonCopula(param=1.0), margins=c("norm","norm"),
                    paramMargins=list(list(mean=0, sd=5),list(mean=0, sd=5)))

#I take a sample of 500 events
sim <- rMvdc(500,copula_dist)
# Compute the density
pdf_mvd <- dMvdc(sim, my_dist)
# Compute the CDF
cdf_mvd <- pMvdc(sim, my_dist)

#I wonder whether this gives me the proba P(X<0.01|Y<0.01)
prob(claytonCopula(param=1.0), c(0,.01),c(0,0.01)) 

I get 25.26% as the output but I am not sure it is correct.


Solution

  • Use the definition of the conditional probability:

    P(X <= a | Y <= b) = P(X <= a, Y <= b) / P(Y <= b)
    

    Then proceed as follows:

    library(copula)
    
    copula <- mvdc(copula=claytonCopula(param=1.0), margins=c("norm","norm"),
                   paramMargins=list(list(mean=0, sd=5),list(mean=0, sd=5)))
    a <- 0.01; b <- 0.01
    pMvdc(c(a,b), copula) / pnorm(b, mean=0, sd=5)
    # 0.6670215