Learn R Programming

copula (version 0.999-14)

contour-methods: Methods for Contour Plots in Package 'copula'

Description

Methods for function contour to draw contour lines aka a level plot for objects from package copula.

Usage

"contour"(x, fun, n = 51, delta = 0, box01 = TRUE, ...)
"contour"(x, fun, xlim, ylim, nx = 51, ny = 51, xis = seq(xlim[1], xlim[2], length = nx), yis = seq(ylim[1], ylim[2], length = ny), box01 = FALSE, ...)

Arguments

x
either a "copula" or a "mvdc" object.
fun
the function to be plotted; typically dCopula or pCopula.
n
(for "copula":) the number of points in both directions to do the plotting. The function fun will be evaluated on a grid of size $n x n$.
delta
a very small number in $[0, 1/2)$, defaulting to zero. The x- and y-ranges to be used for plotting will be [0+delta, 1-delta], i.e., [0,1] by default.
xlim, ylim
("mvdc":) the range of the x or y variable, respectively.
nx,ny
("mvdc":) the number of points in x- or y-direction, respectively. The function fun will be evaluated on a grid of size $nx x ny$.
xis, yis
("mvdc":) instead of specifying xlim, ylim and nx, ny, the numeric vectors (of length nx and ny) may be specified directly.
box01
logical specifying if faint rectangle should be drawn at the $[0,1]^2$ borders (often useful for copulas, but typically not for general multivariate distributions ("mvdc")).
...
further arguments for (the default method of) contour(), e.g., nlevels, levels, etc.

Methods

Contour lines are drawn for "copula" or "mvdc" objects, see x in the Arguments section.

See Also

The persp-methods for “perspective” aka “3D” plots.

Examples

Run this code
contour(frankCopula(-0.8), dCopula)
contour(frankCopula(-0.8), dCopula, delta=1e-6)
contour(frankCopula(-1.2), pCopula)
contour(claytonCopula(2), pCopula)

## the Gumbel copula density is "extreme"
## --> use fine grid (and enough levels):
r <- contour(gumbelCopula(3), dCopula, n=200, nlevels=100)
range(r$z)# [0, 125.912]
## Now superimpose contours of three resolutions:
contour(r, levels=seq(1, max(r$z), by=2), lwd=1.5)
contour(r, levels = (1:13)/2, add=TRUE, col=adjustcolor(1,3/4), lty=2)
contour(r, levels = (1:13)/4, add=TRUE, col=adjustcolor(2,1/2),
        lty=3, lwd=3/4)

x <- mvdc(gumbelCopula(3), c("norm", "norm"),
          list(list(mean = 0, sd =1), list(mean = 1)))
contour(x, dMvdc, xlim=c(-2, 2), ylim=c(-1, 3))
contour(x, pMvdc, xlim=c(-2, 2), ylim=c(-1, 3))

Run the code above in your browser using DataLab