Learn R Programming

copBasic (version 1.5.1)

derCOP: The Numeric Derivative of a Copula

Description

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

Usage

derCOP(cop=NULL, u, v, delu=.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,
delu
The delta u 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

derCOPinv, W, P, M, PSP

Examples

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

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


# Let us contrive a singularity through 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 <- derCOP(cop=afunc,0.5,runif(1),derdir="left")
# The following is correct for given v.
rgt <- derCOP(cop=afunc,0.5,runif(1),derdir="right")
cnt <- derCOP(cop=afunc,0.5,runif(1),derdir="center")
cat(c(lft,rgt,cnt,""))

Run the code above in your browser using DataLab