R: Contour Plot Methods 'contourplot2' in Package 'copula'

contourplot2-methods {copula} | R Documentation

## Contour Plot Methods 'contourplot2' in Package 'copula'

### Description

Methods for `contourplot2()`, a version of `contourplot()` from lattice, to draw contour plots of two dimensional distributions from package copula.

### Usage

    ## NB: The 'matrix' and 'data.frame' methods are identical - documenting the former
    ## S4 method for signature 'matrix'
    contourplot2(x, aspect = 1,
          xlim = range(x[,1], finite = TRUE),
          ylim = range(x[,2], finite = TRUE),
          xlab = NULL, ylab = NULL,
          cuts = 16, labels = !region, pretty = !labels,
          scales = list(alternating = c(1,1), tck = c(1,0)),
          region = TRUE, ...,
          col.regions = gray(seq(0.4, 1, length.out = max(100, 4*cuts))))

    ## S4 method for signature 'Copula'
    contourplot2(x, FUN, n.grid = 26, delta = 0,
          xlim = 0:1, ylim = 0:1,
          xlab = quote(u[1]), ylab = quote(u[2]), ...)
    ## S4 method for signature 'mvdc'
    contourplot2(x, FUN, n.grid = 26, xlim, ylim,
          xlab = quote(x[1]), ylab = quote(x[2]), ...)

### Arguments

`x` | a `"matrix"`, `"data.frame"`, `"Copula"` or a `"mvdc"` object.
`aspect` | the aspect ratio.
`xlim, ylim` | the x- and y-axis limits.
`xlab, ylab` | the x- and y-axis labels. If at least one is `NULL`, useful `xlab` and `ylab` are determined automatically; the behavior depends on the class of `x`.
`cuts` | the number of levels; see `contourplot()`. Note that specifying `useRaster = TRUE` is often considerably more efficient notably for larger values of `cuts`.
`labels, pretty` | `logical`s indicating whether the contour lines are labeled and whether pretty labels are enforced; in copula versions before `0.999-18`, implicitly `pretty = TRUE` was used (giving unequal z-cut spacing), see `contourplot()`.
`scales` | a `list` determining how the axes are drawn; see `contourplot()`.
`region` | a `logical` indicating whether regions between contour lines should be filled as in a level plot; see `contourplot()`.
`col.regions` | the colors of the regions if `region = TRUE`; see `contourplot()`.
`FUN` | the `function` to be plotted; typically `dCopula` or `pCopula`.
`n.grid` | the number of grid points used in each dimension. This can be a vector of length two, giving the number of grid points used in x- and y-direction, respectively; the function `FUN` will be evaluated on the corresponding (x,y)-grid.
`delta` | a small number in [0, 1/2) influencing the evaluation boundaries. The x- and y- vectors will have the range `[0+delta, 1-delta]`, the default being `[0,1]`.
`...` | additional arguments passed to the underlying `contourplot()`.

### Value

An object of class “trellis” as returned by `contourplot()`.

### Methods

Contourplot plots for objects of class `"matrix"` , `"data.frame"`, `"Copula"` or `"mvdc"`.

### See Also

The `contour-methods` for drawing perspective plots via base graphics.

The lattice-based `wireframe2-methods` for functions, and `cloud2-methods` and `splom2-methods` for data.

### Examples

    ## For 'matrix' objects
    ## The Frechet--Hoeffding bounds W and M
    n.grid <- 26
    u <- seq(0, 1, length.out = n.grid)
    grid <- expand.grid("u[1]" = u, "u[2]" = u)
    W <- function(u) pmax(0, rowSums(u)-1) # lower bound W
    M <- function(u) apply(u, 1, min) # upper bound M
    x.W <- cbind(grid, "W(u[1],u[2])" = W(grid)) # evaluate W on 'grid'
    x.M <- cbind(grid, "M(u[1],u[2])" = M(grid)) # evaluate M on 'grid'
    contourplot2(x.W) # contour plot of W
    contourplot2(x.M) # contour plot of M

    ## For 'Copula' objects
    cop <- frankCopula(-4)
    contourplot2(cop, pCopula) # the copula
    contourplot2(cop, pCopula, xlab = "x", ylab = "y") # adjusting the labels
    contourplot2(cop, dCopula) # the density

    ## For 'mvdc' objects
    mvNN <- mvdc(gumbelCopula(3), c("norm", "norm"),
                 list(list(mean = 0, sd = 1), list(mean = 1)))
    xl <- c(-2, 2)
    yl <- c(-1, 3)
    contourplot2(mvNN, FUN = dMvdc, xlim = xl, ylim = yl, contour = FALSE)
    contourplot2(mvNN, FUN = dMvdc, xlim = xl, ylim = yl)
    contourplot2(mvNN, FUN = dMvdc, xlim = xl, ylim = yl, region = FALSE, labels = FALSE)
    contourplot2(mvNN, FUN = dMvdc, xlim = xl, ylim = yl, region = FALSE)
    contourplot2(mvNN, FUN = dMvdc, xlim = xl, ylim = yl,
                 col.regions = colorRampPalette(c("royalblue3", "maroon3"), space="Lab"))

[Package copula version 1.0-1 Index]