我有一个Clayton Copula,变量X和Y,我想得到联合概率和条件概率P(X≤x,Y≤y)和P(X≤x|Y≤y)。例如,如果X低于其第一个百分点,而Y小于其第一个百分点,则概率为P(X≤1%|Y≤1%)
我尝试使用R prob()函数,但不确定输出。
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))
我得到25.26%的输出,但是我不确定它是正确的。
答案 0 :(得分:0)
使用条件概率的定义:
P(X <= a | Y <= b) = P(X <= a, Y <= b) / P(Y <= b)
然后继续进行以下操作:
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