coordinates of points.
The coordinates can be given by two vector arguments
or by a single vector
x.
If a single numeric vector is given,
then
time(x) is plotted on the x-axis
and
x is plotted on the y-axis.
Missing values (
NAs) are allowed;
points containing missing values are omitted from the plot.
lower
pointwise lower limits of the error bars.
This may be a single number or a vector the same length
as
x and
y.
If
incr=TRUE,
then
lower is expected to contain
the lower half widths of the error bars.
If
incr=FALSE,
then
lower contains the coordinates
of the lower limits in terms of
x
or
y, depending on the orientation of the bars.
Missing values (
NAs) are not allowed.
OPTIONAL ARGUMENTS:
upper
pointwise upper limits of the error bars.
This may be a single number or a vector the same length as
x and
y.
If
incr=TRUE, then
upper is expected to contain the upper half widths of the error bars.
If
incr=FALSE,
then
upper contains the coordinates
of the upper limits in terms of
x
or
y, depending on the orientation of the bars.
If
upper is missing,
the upper limits are drawn symmetric to the lower limits.
Missing values (
NAs) are not allowed.
incr
logical flag: do the values in
lower
and
upper represent increments?
If
incr=TRUE,
then
lower and
upper
are assumed to represent half the widths of the error bars (increments).
bar.ends
logical flag: should flat bars be drawn at the endpoints?
This option is provided for purely aesthetic reasons.
add
logical flag: should the error bars be added to the current plot?
If
add=TRUE and a graphics device is open,
the error bars are added to the plot in the open device and no axes are drawn.
In this case, you should use the
plot parameters
xlim and
ylim
to provide enough room for the error bars;
otherwise, "Lines out of bounds" warnings are generated.
If
add=FALSE,
a new coordinate system is set up for the error bar plot and axes are drawn.
gap
logical flag: should gaps be left around the points to emphasize
their locations?
horizontal
logical flag: should the error bars be oriented horizontally?
xlab
character string used for the x-axis label.
xlim
numeric vector of length 2 representing the range for the x-axis.
ylim
numeric vector of length 2 representing the range for the y-axis.
...
additional graphical parameters can be passed to the
plot function.
For more details, see the help file for
par.
SIDE EFFECTS:
Creates a plot of
y
versus
x with pointwise error bars.
SEE ALSO:
,
,
.
EXAMPLES:
# Approximate 95% confidence bands for
# normally distributed y. The error bars are for
# individual values, so we use constant standard errors.
y <- rnorm(20)
std.err.y <- 1
error.bar(y, lower = qnorm(.975) * std.err.y)
# Plot unprocessed data.
# The error bars are for group means, so we divide population
# variance by sample size to obtain standard errors.
# Group memberships.
x <- rep(1:5, c(4,5,6,3,8))
y <- c(12.3, 14.6, 12.7, 13.8, 23.1, 34.2, 32.3, 21.5, 26.4,
56.4, 45.7, 45.9, 50.2, 48.8, 47.2, 80.2, 75.1, 77.8, 50.3,
55.8, 54.2, 51.4, 34.7, 54.9, 49.8, 55.5)
tmp.means <- tapply(y, x, mean)
tmp.se <- sqrt(tapply(y, x, var)/tapply(y, x, length))
error.bar(unique(x), tmp.means, tmp.se, incr = T)
# Use error.bar with predict methods.
attach(gas)
gas.m <- loess(NOx ~ E, data = gas, span = 2/3)
E.new <- seq(min(E), max(E), length = 7)
gas.se <- predict(gas.m, newdata = E.new, se.fit = TRUE)
gas.bars <- pointwise(gas.se)
error.bar(E.new, gas.bars$fit, gas.bars$lower, gas.bars$upper)
detach("gas")