psych (version 1.3.10.12)

errorCircles: Two way plots of means, error bars, and sample sizes

Description

Given a matrix or data frame, data, find statistics based upon a grouping variable and then plot x and y means with error bars for each value of the grouping variable. If the data are paired (e.g. by gender), then plot means and error bars for the two groups on all variables.

Usage

errorCircles(x, y, data, ydata = NULL, group=NULL, paired = FALSE, labels = NULL, 
main = NULL, xlim = NULL, ylim = NULL, xlab = NULL, ylab = NULL,add=FALSE, pos = NULL,
 offset = 1, arrow.len = 0.2, alpha = 0.05, sd = FALSE, bars = TRUE, circles = TRUE, ...)

Arguments

x
The x variable (by name or number) to plot
y
The y variable (name or number) to plot
data
The matrix or data.frame to use for the x data
ydata
If plotting data from two data.frames, then the y variable of the ydata frame will be used.
group
If specified, then statsBy is called first to find the statistics by group
paired
If TRUE, plot all x and y variables for the two values of the grouping variable.
labels
Variable names
main
Main title for plot
xlim
xlim values if desired-- defaults to min and max mean(x) +/- 2 se
ylim
ylim values if desired -- defaults to min and max mean(y) +/- 2 se
xlab
label for x axis -- grouping variable 1
ylab
label for y axis -- grouping variable 2
add
If TRUE, add to the prior plot
pos
Labels are located where with respect to the mean?
offset
Labels are then offset from this location
arrow.len
Arrow length
alpha
alpha level of error bars
sd
if sd is TRUE, then draw means +/- 1 sd)
bars
Should error.bars be drawn for both x and y
circles
Should circles representing the relative sample sizes be drawn?
...
Other parameters for plot

Value

  • If the group variable is specified, then the statistics from statsBy are (invisibly) returned.

Details

When visualizing the effect of an experimental manipulation or the relationship of multiple groups, it is convenient to plot their means as well as their confidence regions in a two dimensional space.

See Also

statsBy, describeBy, error.crosses

Examples

Run this code
#BFI scores for males and females
errorCircles(1:25,1:25,data=bfi,group="gender",paired=TRUE,ylab="female scores",
      xlab="male scores",main="BFI scores by gender")
 abline(a=0,b=1)
#drop the circles since all samples are the same sizes
errorCircles(1:25,1:25,data=bfi,group="gender",paired=TRUE,circles=FALSE,
     ylab="female scores",xlab="male scores",main="BFI scores by gender")
 abline(a=0,b=1)
 
 data(affect)
colors <- c("black","red","white","blue")
films <- c("Sad","Horror","Neutral","Happy")
affect.stats <- errorCircles("EA2","TA2",data=affect,group="Film",labels=films,
      xlab="Energetic Arousal",ylab="Tense Arousal",ylim=c(10,22),xlim=c(8,20), 
      pch=16,cex=2,col=colors, main ="EA and TA pre and post affective movies")
#now, use the stats from the prior run 
errorCircles("EA1","TA1",data=affect.stats,labels=films,pch=16,cex=2,col=colors,add=TRUE)

#Can also provide error.bars.by functionality
 errorCircles(2,5,group=2,data=sat.act,circles=FALSE,pch=16,col="blue",
      ylim= c(200,800),main="SATV by education",labels="")
 #just do the breakdown and then show the points
 errorCircles(3,5,group=3,data=sat.act,circles=FALSE,pch=16,col="blue",
         ylim= c(200,800),main="SATV by age",labels="",bars=FALSE)

Run the code above in your browser using DataCamp Workspace