Chp 3 Methods of Constructing Copulas

# load packages
libs<-c("copBasic","lattice","rgl","magrittr")
invisible(lapply(libs, library, character.only = TRUE))
# use lattice for wireframe
# use rgl for persp3d, etc

The Inversion Method

Ex 3.1

H(x,y) is prob of intersection between the unit circle and rectangle (-inf,x) x (-inf,y)

cop312_0 <- function(u,v){
#  stopifnot(abs(u-1/2)+abs(v-1/2)==1/2)
  
  if (abs(u-v)>1/2) {
    #M
    min(u,v)
  } else if (abs(u+v-1)>1/2) {
    #W
    max(u+v-1,0)
  } else {
    (u+v)/2 - 1/4
  }
  
}

cop312<-function(x,y){
mapply(cop312_0, x,y)
}

cop312(3/4,3/4)
## [1] 0.5
library(scatterplot3d)
x = sort(runif(500))
y = sort(runif(500))
z<-outer(x,y,FUN="cop312")

image(x,y,z)

contour(x,y,z)

# color scheme
num_col<-100
#color <- heat.colors(num_col)
color <- rev(rainbow(num_col, start = 0/6, end = 4/6))


zcol  <- cut(z, num_col)
persp3d(x,y,z, col=color[zcol])
#z = mapply(FUN = cop312, x, y)

#scatterplot3d(x,y,z)

Geometric Methods

Algebraic Methods

Copulas with Specified Properties

Constructing Multivariate Copulas