Description Usage Arguments Details Value Functions Author(s) See Also Examples
Generates an ellipse augmented with conjugate axes and tangents
ell is a utility function used to calculate the (X, Y) coordinates of
a 2D ellipse for the purpose of drawing statistical diagrams and plots.
1 2 3 4 5 6 7 |
center |
(default: c(0,0)) |
shape |
(default: diag(2)) 'variance' corresponding to shape of ellipse if taken as a concentration ellipse for a bivariate normal |
radius |
(default: 1) |
n |
(default: 100) number of points generated |
angles |
(default (0:n)*2*pi/n) at which points are generated. The angles refer to the generating circle that is then transformed linearly to form the ellipse |
fac |
(default: chol) method use to factor 'shape' |
ellipse |
Logical to indicate if the points on the ellipse should be returned |
diameters |
Logical to indicate if the points defining the ends of the conjugate axes of the ellipse should be returned |
box |
Logical to indicate if the points on the conjugate-axes bounding box should be returned |
all |
Logical to request all of |
x, y |
data values |
... |
arguments passed to |
center |
X,Y location of the center of the ellipse |
shape |
A 2x2 matrix, typically a covariance matrix of data (for a data ellipse), or a covariance matrix of estimated parameters in a model (for a confidence ellipse). |
radius |
Radius of the ellipse-generating unit circle. The default,
|
n |
Number of points on the unit circle used to calculate the ellipse |
angles |
Angles around the unit circle used to calculate the ellipse |
fac |
A function defining the conjugate axes used to transform the unit
circle into an ellipse. The default, |
ellplus can produce, in addition to the points of an ellipse, the conjugate axes corresponding to a chol or other decomposition and the surrounding parallelogram.
ellplus can produce, in addition, the
conjugate axes corresponding to a chol or other decomposition and the
surrounding parallelogram defined by these axes.
Add function that works with direction to compute slices and conjugate directions.
Returns a 2-column matrix of (X,Y) coordinates suitable for drawing
with lines().
For ellplus, when more than one of the options ellipse,
diameters, and box is TRUE, the different parts are
separated by a row of NA.
ellplus: tangents and axes
dellplus: data ellipse with tangents and axes
Georges Monette
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | plot( x=0,y=0, xlim = c(-3,3), ylim = c(-3,3),
xlab = '', ylab = '', type = 'n', asp=1)
abline( v=0, col="gray")
abline( h=0, col="gray")
A <- cbind( c(1,2), c(1.5,1))
W <- A %*% t(A)
lines( ell(center=c(0,0), shape = W ), col = 'blue', lwd=3)
lines( ellplus(center=c(0,0), shape = W, box=TRUE, diameters=TRUE ), col = 'red')
# show conjugate axes for PCA factorization
pca.fac <- function(x) {
xx <- svd(x)
ret <- t(xx$v) * sqrt(pmax( xx$d,0))
ret
}
plot( x=0,y=0, xlim = c(-3,3), ylim = c(-3,3),
xlab = '', ylab = '', type = 'n', asp=1)
abline( v=0, col="gray")
abline( h=0, col="gray")
lines( ell(center=c(0,0), shape = W ), col = 'blue', lwd=3)
lines( ellplus(center=c(0,0), shape = W, box=TRUE, diameters=TRUE, fac=pca.fac ), col = 'red')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.