rhoCOP(cop=PSP) # 0.4784176
rhoCOP(cop=PSP, brute=TRUE) # 0.4684063
# CPU heavy example showing that the dual-integration (fast) results in
# a Spearman's Rho that mimics a sample version
dorho <- function(n) {
uv <- simCOP(n=n, cop=PSP, ploton=FALSE, points=FALSE)
return(cor(uv$U, uv$V, method="spearman"))
}
rhos <- replicate(100, dorho(1000))
rho.sample <- mean(rhos); print(rho.sample) # 0.472661
para <- list(cop1=PLACKETTcop, cop2=PLACKETTcop,
para1=0.00395, para2=4.67, alpha=0.9392, beta=0.5699)
rhoCOP(cop=composite2COP, para=para) # -0.5924796
para <- list(cop1=PLACKETTcop, cop2=PLACKETTcop,
para1=0.14147, para2=20.96, alpha=0.0411, beta=0.6873)
rhoCOP(cop=composite2COP, para=para) # 0.2818874
para <- list(cop1=PLACKETTcop, cop2=PLACKETTcop,
para1=0.10137, para2=4492.87, alpha=0.0063, beta=0.0167)
rhoCOP(cop=composite2COP, para=para) # 0.9812919
rhoCOP(cop=composite2COP, para=para, brute=TRUE) # 0.9752155
# This is the same composited copula used in a highly asymmetric multi-modal
# plotting example under densityCOPplot(). Let us use that copula as a means to
# check on the Spearman's Rho from the alternative formulations from Joe (2015).
para <- list(alpha=0.15, beta=0.90, kappa=0.06, gamma=0.96,
cop1=GHcop, cop2=PLACKETTcop, para1=5.5, para2=0.07)
"rhoCOPbyJoe21" <- function(cop=NULL, para=NULL, ...) { # Joe (2015, eq. 2.48)
myint <- NULL
try(myint <- integrate(function(u) {
sapply(u,function(u) { integrate(function(v) {
u * derCOP( u, v, cop=cop, para=para, ...)}, 0, 1)$value })}, 0, 1))
ifelse(is.null(myint), return(NA), return(3 - 12*myint$value))
}
"rhoCOPbyJoe12" <- function(cop=NULL, para=NULL, ...) { # Not in Joe (2015)
myint <- NULL
try(myint <- integrate(function(u) {
sapply(u,function(u) { integrate(function(v) {
v * derCOP2( u, v, cop=cop, para=para, ...)}, 0, 1)$value })}, 0, 1))
ifelse(is.null(myint), return(NA), return(3 - 12*myint$value))
}
rhoCOP( cop=composite2COP, para=para) # 0.1031758
rhoCOPbyJoe21(cop=composite2COP, para=para) # 0.1031803
rhoCOPbyJoe12(cop=composite2COP, para=para) # 0.1031532
Run the code above in your browser using DataLab