【问题标题】:Expected values from copula in RR中copula的期望值
【发布时间】:2019-06-12 20:22:45
【问题描述】:

我有一个表示两个变量 X 和 Y 之间依赖关系的 copula。我想计算以下公式:E(X|Y≤1%)。它是以 Y 低于 1% 为条件的 X 的期望值。 我看到there 提出了一个类似的问题,但提供的 R 代码没有给出我正在寻找的值。 以下是有关 copula 和边际分布的一些细节。

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)

【问题讨论】:

    标签: r distribution probability-distribution


    【解决方案1】:

    你必须计算这个双积分:integral of x*pdf(x,y), -oo &lt; x &lt; +oo, -oo &lt; y &lt; 1%,然后除以Pr(Y &lt; 1%)。这是在下面完成的。我还通过模拟进行近似以进行检查。

    library(copula)
    
    # the distribution
    copula_dist <- mvdc(copula=claytonCopula(param=1.0), margins=c("norm","norm"),
                        paramMargins=list(list(mean=0, sd=5),list(mean=0, sd=5)))
    
    ### we will calculate E[X | Y < y0]
    y0 <- 1/100
    
    ### approximation of E[X | Y < y0] using simulations
    sim <- rMvdc(100000, copula_dist)
    mean(sim[sim[,2]<y0,1])
    # [1] -1.967642
    
    ### approximation of E[X | Y < y0] using numerical integration
    ### this is E[X * 1_{Y<y0}] / P(Y < y0)
    library(cubature)
    # PDF of the distribution 
    pdf <- function(xy) dMvdc(xy, copula_dist)
    # P(Y < y0)
    denominator <- pnorm(y0, mean=0, sd=5)
    # integrand
    f <- function(xy) xy[1] * pdf(xy)
    # integral
    integral <- hcubature(f, lowerLimit = c(-Inf, -Inf), upperLimit = c(Inf, y0))
    integral$integral / denominator
    # [1] -1.942691
    

    【讨论】:

    • 感谢一百万斯蒂芬!
    • @Sabotar 很高兴为您提供帮助。请问accept the answer.
    • 明确一点,数学公式是x的积分pdf(x,y), -oo pdf(x,y), -oo
    猜你喜欢
    • 1970-01-01
    • 2019-12-08
    • 1970-01-01
    • 2019-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-30
    • 1970-01-01
    相关资源
    最近更新 更多