car (version 2.0-11)

Ellipses: Ellipses, Data Ellipses, and Confidence Ellipses

Description

These functions draw ellipses, including data ellipses, and confidence ellipses for linear and generalized linear models.

Usage

ellipse(center, shape, radius, log="", center.pch=19, center.cex=1.5, 
  segments=51, draw=TRUE, add=draw, xlab="", ylab="", 
   col=palette()[2], lwd=2, fill=FALSE, fill.alpha=0.3, grid=TRUE, ...)

dataEllipse(x, y, log="", levels=c(0.5, 0.95), center.pch=19, center.cex=1.5, 
  draw=TRUE, plot.points=draw, add=!plot.points, segments=51, robust=FALSE,
  xlab=deparse(substitute(x)), 
  ylab=deparse(substitute(y)), 
  col=palette()[1:2], lwd=2, fill=FALSE, fill.alpha=0.3, grid=TRUE, ...)

confidenceEllipse(model, ...)

## S3 method for class 'lm':
confidenceEllipse(model, which.coef, levels=0.95, Scheffe=FALSE, 
  center.pch=19, center.cex=1.5, segments=51, xlab, ylab, 
  col=palette()[2], lwd=2, fill=FALSE, fill.alpha=0.3, draw=TRUE, add=!draw, ...)

## S3 method for class 'glm':
confidenceEllipse(model, which.coef, levels=0.95, Scheffe=FALSE, 
  center.pch=19, center.cex=1.5, segments=51, xlab, ylab, 
  col=palette()[2], lwd=2, fill=FALSE, fill.alpha=0.3, draw=TRUE, add=!draw, ...)

Arguments

center
2-element vector with coordinates of center of ellipse.
shape
$2\times 2$ shape (or covariance) matrix.
radius
radius of circle generating the ellipse.
log
when an ellipse is to be added to an existing plot, indicates whether computations were on logged values and to be plotted on logged axes; "x" if the x-axis is logged, "y" if the y-axis is logged, and "xy"
center.pch
character for plotting ellipse center.
center.cex
relative size of character for plotting ellipse center.
segments
number of line-segments used to draw ellipse.
draw
if TRUE produce graphical output; if FALSE, only invisibly return coordinates of ellipse(s).
add
if TRUE add ellipse(s) to current plot.
xlab
label for horizontal axis.
ylab
label for vertical axis.
x
a numeric vector, or (if y is missing) a 2-column numeric matrix.
y
a numeric vector, of the same length as x.
plot.points
if FALSE data ellipses are drawn, but points are not plotted.
levels
draw elliptical contours at these (normal) probability or confidence levels.
robust
if TRUE use the cov.trob function in the MASS package to calculate the center and covariance matrix for the data ellipse.
model
a model object produced by lm or glm.
which.coef
2-element vector giving indices of coefficients to plot; if missing, the first two coefficients (disregarding the regression constant) will be selected.
Scheffe
if TRUE scale the ellipse so that its projections onto the axes give Scheffe confidence intervals for the coefficients.
col
color for lines and ellipse center; the default is the second entry in the current color palette (see palette and par). For <
lwd
line width; default is 2 (see par).
fill
fill the ellipse with translucent color col (default, FALSE)?
fill.alpha
transparency of fill (default = 0.3).
...
other plotting parameters to be passed to plot and line.
grid
If TRUE, the default, a light-gray background grid is put on the graph

Value

  • These functions are mainly used for their side effect of producing plots. For greater flexibility (e.g., adding plot annotations), however, ellipse returns invisibly the (x, y) coordinates of the calculated ellipse. dataEllipse and confidenceEllipse return invisibly the coordinates of one or more ellipses, in the latter instance a list named by levels.

Details

The ellipse is computed by suitably transforming a unit circle. dataEllipse superimposes the normal-probability contours over a scatterplot of the data.

References

Fox, J. (2008) Applied Regression Analysis and Generalized Linear Models, Second Edition. Sage. Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage. Monette, G. (1990) Geometry of multiple regression and 3D graphics. In Fox, J. and Long, J. S. (Eds.) Modern Methods of Data Analysis. Sage.

See Also

cov.trob.

Examples

Run this code
dataEllipse(Prestige$income, Prestige$education, levels=0.1*1:9, lty=2, 
	fill=TRUE, fill.alpha=0.1)
confidenceEllipse(lm(prestige~income+education, data=Prestige), Scheffe=TRUE)

Run the code above in your browser using DataCamp Workspace