Learn R Programming

fixest (version 0.5.1)

errbar: Plots confidence intervals

Description

This function draws confidence intervals in a graph.

Usage

errbar(
  estimate,
  sd,
  ci_low,
  ci_top,
  x,
  x.shift = 0,
  w = 0.1,
  ci_level = 0.95,
  style = c("bar", "interval", "tube"),
  add = FALSE,
  col = 1,
  bar.col = col,
  bar.lwd = par("lwd"),
  bar.lty,
  grid = TRUE,
  grid.par = list(lty = 1),
  bar.join = FALSE,
  only.params = FALSE,
  ...
)

Arguments

estimate

Numeric vector. The point estimates.

sd

The standard errors of the estimates. It may be missing.

ci_low

If sd is not provided, the lower bound of the confidence interval. For each estimate.

ci_top

If sd is not provided, the upper bound of the confidence interval. For each estimate.

x

The value of the x-axis. If missing, the names of the argument estimate is used.

x.shift

Shifts the confidence intervals bars to the left or right, depending on the value of x.shift. Default is 0.

w

The width of the confidence intervals.

ci_level

Scalar between 0 and 1: the level of the CI. By default it is equal to 0.95.

style

If “interval”: it plots a confidence interval. If “bar”, it plots simply error bars. If “tube”: as interval, but with a grayed area.

add

Default is FALSE, if the intervals are to be added to an existing graph. Note that if it is the case, then the argument x MUST be numeric.

col

Color of the point estimate and of the line joining them (if style = "interval").

bar.col

Color of the bars of the confidence interval. Defaults to col.

bar.lwd

Line width of the confidence intervals, defaults to 1.

bar.lty

Line type of the confidence intervals, defaults to 1 for style = "bar" and to 2 for style = "interval".

grid

Whether to add an horizontal grid. Default is TRUE.

grid.par

Graphical parameters used when plotting the grid in the background. Default is list(lty=1).

bar.join

Logical, default is FALSE. Whether to join the dots when style = "bar".

only.params

Logical, default is FALSE. If TRUE: no graph is plotted, only the ylim is returned. Useful to stack estimates from different estimations in the same graph.

...

Other arguments to be passed to the function plot or lines (if add = TRUE).

See Also

fixest-deprecated

Examples

Run this code
# NOT RUN {
a = rnorm(100)
b = 0.5*a + rnorm(100)
c = -0.5*b + rnorm(100)

est = summary(lm(a ~ c + b))

errbar(est$coefficients, x.shift = -.2)

errbar(est$coefficients, x.shift = .2, add = TRUE, col = 2, bar.lty = 2, pch=15)

# }

Run the code above in your browser using DataLab