CIplot_biv {easyCODA} | R Documentation |
Bivariate confidence and data ellipses
Description
Draws confidence and data ellipses in bivariate scatterplots
Usage
CIplot_biv(x, y, group, wt=rep(1/length(x),length(x)),
varnames=c("x","y"), groupnames=sort(unique(group)),
groupcols=rainbow(length(unique(group))),
shownames=TRUE, xlim=c(NA,NA), ylim=c(NA,NA),
lty=1, lwd=1, add=FALSE, alpha=0.95, ellipse=0,
shade=FALSE, frac=0.01, cex=1)
Arguments
x |
x-variable (horizontal) of scatterplot |
y |
y-variable (vertical) of scatterplot |
group |
Grouping variable |
wt |
Set of weights on the cases (operates when ellipse=1) |
varnames |
Vector of two labels for the axes (default is x and y) |
groupnames |
Vector of labels for the groups (default is 1, 2, etc...) |
groupcols |
Vector of colours for the groups |
shownames |
Whether to show group names at group centroids or not (default is |
xlim |
Possible new x-limits for plot |
ylim |
Possible new y-limits for plot |
lty |
Line type for the ellipses (default is 1) |
lwd |
Line width for the ellipses (default is 1) |
add |
= |
alpha |
Confidence level of ellipses (default is 0.95) |
ellipse |
Type of ellipse (see Details below; default is 0 for normal-based ellipses) |
shade |
= |
frac |
Proportional part defining the width of the bars at the edges of confidence intervals (for |
cex |
Character expansion factor for group names |
Details
The function CIplot_biv
makes various types of confidence and data ellipses, according to option ellipse
. Set ellipse<0
for regular data-covering ellipses. Set ellipse=0
(default) for normal-theory confidence ellipses. Setellipse=1
for bootstrap confidence ellipses. The option ellipse=2
for the delta method is not implemented yet. Set ellipse=3
for normal-theory confidence error bars lined up with axes. Set ellipse=4
for bootstrap confidence error bars along axes. The package ellipse
is required.
Author(s)
Michael Greenacre
References
Greenacre, M. (2016), Data reporting and visualization in ecology, Polar Biology, 39:2189-2205.
See Also
Examples
# Generate some bivariate normal data in three groups with different means
# Means (1,0), (0,1) and (0,0)
means <- matrix(c(1,0,0,1,0,0), ncol=3)
data <- matrix(nrow=300, ncol=2)
groups <- sample(rep(c(1,2,3), 100))
for(i in 1:300) data[i,] <- rnorm(c(1,1), mean=means[,groups[i]])
# Plot confidence ellipses with shading
CIplot_biv(data[,1], data[,2], group=groups, shade=TRUE)