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

    ## 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,
          scales = list(alternating = c(1,1), tck = c(1,0)),
          region = TRUE, ...,
          col.regions = gray(seq(0.4, 1, length.out = 100)))
    ## S4 method for signature 'data.frame'
    contourplot2(x, aspect = 1,
          xlim = range(x[,1], finite = TRUE),
          ylim = range(x[,2], finite = TRUE),
          xlab = NULL, ylab = NULL,
          cuts = 16, labels = !region,
          scales = list(alternating = c(1,1), tck = c(1,0)),
          region = TRUE, ...,
          col.regions = gray(seq(0.4, 1, length.out = 100)))
    ## S4 method for signature 'Copula'
    contourplot2(x, FUN, n.grid = 26, xlim = 0:1, ylim = 0:1,
          xlab = expression(u[1]), ylab = expression(u[2]), ...)
    ## S4 method for signature 'mvdc'
    contourplot2(x, FUN, n.grid = 26, xlim, ylim,
          xlab = expression(x[1]), ylab = expression(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()`.
`labels` | a `logical` indicating whether the contour lines are labeled; 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.
`...` | 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.

### 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 0.999-15 Index]