psych (version 1.0-42)

error.bars.by: Plot means and confidence intervals for multiple groups

Description

One of the many functions in R to plot means and confidence intervals. Meant mainly for demonstration purposes for showing the probabilty of replication from multiple samples. Can also be combined with such functions as boxplot to summarize distributions. Means and standard errors for each group are calculated using describe.by.

Usage

error.bars.by(x, group,by.var = FALSE,x.cat=TRUE, ylab = "NULL", xlab = "NULL",main="95% Confidence Intervals", ylim = NULL, ci = 1.96, labels = NULL, pos = NULL, arrow.len = 0.05, add = FALSE, ...)

Arguments

x
A data frame or matrix
group
A grouping variable
by.var
A different line for each group (default) or each variable
x.cat
Is the grouping variable categorical (TRUE) or continuous (FALSE
ylab
y label
xlab
x label
main
title for figure
ylim
if specified, the limits for the plot, otherwise based upon the data
ci
What size confidence interval to use
labels
X axis label
pos
where to place text: below, left, above, right
arrow.len
How long should the top of the error bars be?
add
add=FALSE, new plot, add=TRUE, just points and error bars
...
other parameters to pass to the plot function, e.g., typ="b" to draw lines, lty="dashed" to draw dashed lines

Value

  • Graphic output showing the means + x% confidence intervals for each group. For ci=1.96, and normal data, this will be the 95% confidence region. For ci=1, the 68% confidence region.

Details

Drawing the mean +/- a confidence interval is a frequently used function when reporting experimental results. By default, the confidence interval is 1.96 standard errors.

This function is a wrapper for error.bars and allows groups to be organized either as the x axis or as separate lines.

See Also

See Also as error.crosses, error.bars

Examples

Run this code
x <- matrix(rnorm(500),ncol=20)
y <- sample(4,25 ,replace=TRUE)
x <- x+y
error.bars.by(x,y)
error.bars.by(x,y,TRUE)

Run the code above in your browser using DataCamp Workspace