Learn R Programming

phonTools (version 0.1-5)

sdellipse: Standard deviation Ellipse

Description

Draw standard deviation ellipses around a group of observations.

Usage

sdellipse (points, stdev = 1.96, density = .1, output = FALSE, add = TRUE, show = TRUE, ...)

Arguments

points
A matrix with two columns in which each row is a different observation from a bivariate normal distribution.
stdev
The number of standard deviations to be enclosed by the ellipse.
density
The spacing between sampling points along the ellipse. A higher number results in a coarser sampling.
output
If TRUE, the points used to draw the ellipse are returned.
add
If TRUE, the ellipse is added to an existing plot. If FALSE, a new plot is created.
show
If FALSE, no ellipse is drawn.
...
Additional arguments are passed to the internal call of lines() or plot() as appropriate.

Value

  • If output = TRUE, a matrix is returned where the first column indicate x-axis ellipse coordinates and the second column indicates y-axis ellipse coordinates.

Examples

Run this code
## Examples of draws from different bivariate normal distributions
## and standard deviation ellipses drawn to fit them.
par (mfrow = c(2,2))
draws = rmvtnorm (n = 10000, k = 2, sigma = .3)
plot (draws)
sdellipse (draws, stdev = 3, lwd = 3, col = 2)

draws = rmvtnorm (n = 10000, k = 2, sigma = -.3)
plot (draws)
sdellipse (draws, stdev = 3, lwd = 3, col = 2)

draws = rmvtnorm (n = 10000, k = 2, sigma = -.7)
plot (draws)
sdellipse (draws, stdev = 3, lwd = 3, col = 2)

draws = rmvtnorm (n = 10000, k = 2, sigma = .7)
plot (draws)
sdellipse (draws, stdev = 3, lwd = 3, col = 2)

Run the code above in your browser using DataLab