Creates barplots for displaying statistical summaries by treatment (e.g. means, medians, M-estimates of location, standard deviation, variance, etc.) and
their error estimates by treatment (i.e. standard errors, confidence intervals, IQRs, IQR confidence intervals, and MAD intervals). Custom intervals can also be created.
The function can also be used to display letters indicating if comparisons of locations are significant after adjustment for simultaneous inference (see pairw.anova
, pairw.kw
, and/or pairw.fried
).
bplot(y, x, bar.col = "gray", loc.meas = mean, sort = FALSE, order = NULL, int = "SE",
conf = 0.95, uiw = NULL, liw = NULL, sfrac = 0.1, slty = 1, scol = 1,
slwd = 1, exp.fact = 1.5, simlett = FALSE, lett.side = 3, lett = NULL,
cex.lett = 1, names.arg = NULL, ylim = NULL, horiz = FALSE, xpd = FALSE,
print.summary = TRUE, ...)
A plot is returned. Bar centers (ala barplot
) are returned invisibly.
A quantitative vector representing the response variable.
A categorical vector representing treatments (e.g. factor levels).
Color of bar.
Measure of location or other summary statistic, e.g. mean, median, etc.
Logical, if TRUE
, then treatments are ordered by their location statistics.
A vector of length equal to the number of factor levels, specifying the order of bars with respect to the alphanumeric order of their names.
Type of error bar to be drawn, must be one of "SE"
, "CI"
, IQR
, "MAD"
, "IQR.CI"
or "bootSE"
. IQR-derived confidence intervals are based on \(\pm-1.58 IQR/\sqrt{n}\) and provide an approximate 95% confidence interval for the difference in two medians. The measure can be attributed to Chambers et al. (1983, p. 62), given McGill et al. (1978, p. 16). It is based on asymptotic normality of the median and assumes roughly equal sample sizes for the two medians being compared. The interval is apparently insensitive to the underlying distributions of the samples. The specification "bootSE"
gives bootstrap SEs for the location measure using the function bootstrap
Level of confidence, 1 - P(type I error).
Upper y-coordinate for the error bar, if NULL
then this will be computed from int
.
Lower y-coordinate for the error bar, if NULL
then this will be computed from int
.
Scaling factor for the size of the "serifs" (end bars) on the confidence bars, in x-axis units.
Line type for error bars.
Line color for error bars.
Line width for error bars.
A multiplication factor indicating how much extra room is made for drawing letters in top of graph. Only used if simlett = TRUE
.
A logical statement indicating whether or not letters should be shown above bars indicating that populations means have been determined to be significantly different.
Side that letters will be drawn on, 1 = bottom, 2 = left, 3 = top, 4 = right.
A vector of letters or some other code to display multiple comparison results.
Character expansion for multiple comparison result letters.
A vector of names to be plotted below each bar or error bar. If this argument is omitted, then the names are taken from the names attribute of y
.
Upper and lower limits of the Y-axis
Logical value. If FALSE
, then bars are drawn vertically with the first bar to the left. If TRUE
, then bars are drawn horizontally with the first at the bottom.
Logical value. If FALSE
, this overrides barplot
designation xpd = TRUE
, which may cause bars to extend off the plot if ylim
is modified.
Logical value. If TRUE
a summary of the location and dispersion measures used in the plot is printed.
Additional arguments from barplot
.
Ken Aho
It is often desirable to display the results of a pairwise comparison procedure using sample measures of location and error bars. This functions allows these sorts of plots to be made. The function is essentially a wrapper for the function barplot
.
Chambers, J. M., Cleveland, W. S., Kleiner, B. and Tukey, P. A. (1983) Graphical Methods for Data Analysis. Wadsworth & Brooks/Cole.
McGill, R., Tukey, J. W. and Larsen, W. A. (1978) Variations of box plots. The American Statistician 32, 12-16.
eggs<-c(11,17,16,14,15,12,10,15,19,11,23,20,18,17,27,33,22,26,28)
trt<-c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,4,4,4,4,4)
bplot(y=eggs, x=factor(trt),int="SE",xlab="Treatment",ylab="Mean number of eggs",
simlett=TRUE, lett=c("b","b","b","a"))
Run the code above in your browser using DataLab