bplot: Barplots with error bars (including interval plots)

bplotR Documentation

Barplots with error bars (including interval plots)

Description

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).

Usage

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, ...)

Arguments

y

A quantitative vector representing the response variable.

x

A categorical vector representing treatments (e.g. factor levels).

bar.col

Color of bar.

loc.meas

Measure of location or other summary statistic, e.g. mean, median, etc.

sort

Logical, if TRUE, then treatments are ordered by their location statistics.

order

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.

int

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

conf

Level of confidence, 1 - P(type I error).

uiw

Upper y-coordinate for the error bar, if NULL then this will be computed from int.

liw

Lower y-coordinate for the error bar, if NULL then this will be computed from int.

sfrac

Scaling factor for the size of the "serifs" (end bars) on the confidence bars, in x-axis units.

slty

Line type for error bars.

scol

Line color for error bars.

slwd

Line width for error bars.

exp.fact

A multiplication factor indicating how much extra room is made for drawing letters in top of graph. Only used if simlett = TRUE.

simlett

A logical statement indicating whether or not letters should be shown above bars indicating that populations means have been determined to be significantly different.

lett.side

Side that letters will be drawn on, 1 = bottom, 2 = left, 3 = top, 4 = right.

lett

A vector of letters or some other code to display multiple comparison results.

cex.lett

Character expansion for multiple comparison result letters.

names.arg

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.

ylim

Upper and lower limits of the Y-axis

horiz

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.

xpd

Logical value. If FALSE, this overrides barplot designation xpd = TRUE, which may cause bars to extend off the plot if ylim is modified.

print.summary

Logical value. If TRUE a summary of the location and dispersion measures used in the plot is printed.

...

Additional arguments from barplot.

Details

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.

Value

A plot is returned. Bar centers (ala barplot) are returned invisibly.

Author(s)

Ken Aho

References

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.

See Also

mad, barplot, pairw.anova, pairw.kw, pairw.fried

Examples

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"))

asbio documentation built on May 29, 2024, 5:57 a.m.