Learn R Programming

copBasic (version 1.5.1)

derCOP2: The Numeric Derivative of a Copula

Description

Compute the numeric derivative of a copula according to Nelson (2006), but with respect to $v$ and not $u$ $$\mathrm{Pr}[U \le u\mid V=v] = \lim_{\Delta v \rightarrow 0}\frac{\mathbf{C}(u, v+\Delta v) - \mathbf{C}(u,v)}{\Delta v}$$ which is to read at the probability that $U \le u$ given that $V = v$ and corresponds to the derdir="left" mode of the function. For derdir="right", we have $$\mathrm{Pr}[U \le u\mid V=v] = \lim_{\Delta v \rightarrow 0}\frac{\mathbf{C}(u,v) - \mathbf{C}(u, v-\Delta v)}{\Delta v}$$ and for derdir="center" (the usual method of computing a derivative), we have $$\mathrm{Pr}[U \le u\mid V=v] = \lim_{\Delta v \rightarrow 0}\frac{\mathbf{C}(u,v+\Delta v) - \mathbf{C}(u, v-\Delta v)}{2 \Delta v}$$

Usage

derCOP2(cop=NULL, u, v, delv=.Machine$double.eps^0.50,
        derdir=c("left","right","center"), ...)

Arguments

cop
A copula function,
u
A nonexceedance probability in X direction,
v
A nonexceedance probability in Y direction,
delv
The delta v interval for the derivative,
derdir
The direction of the derivative as described above. Default is left, and
...
Additional arguments to pass.

Value

  • The value for the copula is returned.

References

Nelson, R.B., 2006, An introduction to copulas: New York, Springer, 269 p.

See Also

derCOPinv2, W, P, M, PSP

Examples

Run this code
derCOP2(cop=W,0.4,0.6)
derCOP2(cop=P,0.4,0.6)
derCOP2(cop=M,0.4,0.6)
derCOP2(cop=PSP,0.4,0.6)

lft <- derCOP2(cop=P,0.4,0.6, derdir="left")
rgt <- derCOP2(cop=P,0.4,0.6, derdir="right")
cnt <- derCOP2(cop=P,0.4,0.6, derdir="center")
stopifnot(all.equal(lft,rgt), all.equal(lft,cnt))


# Let us contrive a singularity though this NOT A COPULA
# in the function "afunc"
"afunc" <- function(u,v, ...) {
  if(u <= 0.5) return(sqrt(u^2+v^2))
  return(P(u,v,...)) # The product copula
}
lft <- derCOP2(cop=afunc,0.5,runif(1),derdir="left")
# The following is correct for given v.
rgt <- derCOP2(cop=afunc,0.5,runif(1),derdir="right")
cnt <- derCOP2(cop=afunc,0.5,runif(1),derdir="center")
cat(c(lft,rgt,cnt,""))

Run the code above in your browser using DataLab