pc.ellipse.plot: Principal Component Plot with Ellipsoids

Description Usage Arguments Details Author(s) Examples

View source: R/pc.ellipse.plot.R

Description

Function generates a principal component plot to best view ellipsoids in low dimensions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
pc.ellipse.plot(
  dat,
  std = FALSE,
  PC = c(1, 2),
  confidence = NULL,
  ellipse.density = 120,
  group = NULL,
  group.cols = NULL,
  group.lwd = NULL,
  group.lty = NULL,
  ...
)

Arguments

dat

A matrix or data frame of data

std

A logical value that if TRUE finds standard deviates of the data (data are both centered and scaled by variable standard deviations).

PC

A vector of length 2 to indicate which PCs to view. The default is c(1, 2). This can be changed to view alternative dimensions. Illogical requests will defualt to c(1, 2) with a warning

confidence

The confidence level for ellipsoids, based on the covariance matrix of data by groups. Multivariate normality is assumed in estimation. If NULL, then ellipsoids merely reflect the span of eigenvalues for the covariance matrix of the data. Otherwise, the value should be between 0.01 and 1.

ellipse.density

A numeric value to indicate how many discrete points (in a circle) are used to approximate the continuous ellipse function. More points mean a more precise curve, but increase computation time. The default, 120 points, is the same as 3 degrees (pi/60 radians) increments.

group

A factor of vector coercible to factor. If null, the a single convex hull with be returned.

group.cols

A optional vector with length equal to the number of group levels to describe the colors of the hulls. If NULL, R standard colors will be used.

group.lwd

A optional vector with length equal to the number of group levels to describe the line weight (magnification) of the hulls. If NULL, group.lwd = 1 will be used.

group.lty

A optional vector with length equal to the number of group levels to describe the line type of the hulls. If NULL, group.lty = 1 (solid line) will be used.

...

other arguments for graphical parameters

Details

Principal components are obtained from eigen analysis of an among-group covariance or correlation matrix. (Correlation matrix is used if std = TRUE.) Typical plot parameters should be available but parameters for ellipsoids are controlled with specific function arguments. One can add points, lines, arrows, or a legend to the plot canvas, among other plot tricks, if desired. (See points, lines, arrows, and legend).

Note that the PC plot is 2-dimensional, so the ellipsoids are ellipses. However, the ellipses are 2-dimensional projections of ellipsoids in the full data space. If original data are 2-dimensional, the plot simply rotates the data and ellispes to best align with variation among grup centroids (means).

Author(s)

Michael Collyer

Examples

1
2
3
4
library(RRPP)
data("Pupfish")
group <- interaction(Pupfish$Sex, Pupfish$Pop)
pc.ellipse.plot(Pupfish$coords, group = group)

mlcollyer/ACHC documentation built on May 30, 2020, 10:26 p.m.