Learn R Programming

depth (version 2.1-1.1)

perspdepth: Perspective plots for depth functions

Description

Draws a perspective plot of the surface of a depth function over the x-y plane.

Usage

perspdepth(x, method = "Tukey", output = FALSE, tt = 50, 
   xlab = "X", ylab = "Y", zlab = NULL, col = NULL, ...)

Arguments

x

Bivariate data as a matrix, data frame or list. If it is a matrix or data frame, then each row is viewed as one bivariate observation. If it is a list, both components must be numerical vectors of equal length (coordinates of observations).

method

Character string which determines the depth function used. method can be "Tukey" (the default), "Liu" or "Oja".

output

Logical. Default FALSE produces a perspective plot; otherwise, returns a list containing the grid points and depth values over these points.

tt

Gridsize. Number of equally spaced grid points in each coordinate direction to be used in perspective plot.

xlab

Title for x-axis. Must be a character string.

ylab

Title for y-axis. Must be a character string.

zlab

Title for z-axis. Must be a character string. Default NULL identifies the depth function.

col

Color of the surface plot. Default NULL is "lightblue".

...

Any additional graphical parameters.

Value

Default output = FALSE yields a perspective plot; otherwise the function returns a list with components

x

x-coordinates of the grid where the depth function is evaluated.

y

y-coordinates of the grid where the depth function is evaluated.

z

Matrix whose entry z[i ,j] is the value of the depth function at (x[i], y[j]).

Details

Requires the rgl package. The perspective plot takes advantage of some of the user interaction facilities of that package.

References

Rousseuw, P.J. and Ruts, I. (1996), AS 307 : Bivariate location depth, Appl. Stat.-J. Roy. S. C, 45, 516--526.

See Also

isodepth, depth

Examples

Run this code
# NOT RUN {
## 2 perspective plots
data(geyser, package = "MASS")
perspdepth(geyser, col = "magenta")
set.seed(159); library(MASS)
mu1 <- c(0,0); mu2 <- c(6,0); sigma <- matrix(c(1,0,0,1), nc = 2)
mixbivnorm <- rbind(mvrnorm(80, mu1, sigma),mvrnorm(20, mu2, sigma))
perspdepth(mixbivnorm, col = "chartreuse")

## grid coordinates and corresponding depth values
set.seed(601)
x <- matrix(rnorm(48), nc = 2)
perspdepth(x, output = TRUE, tt = 10)
# }

Run the code above in your browser using DataLab