plotci | R Documentation |
Modification to the plot
function that adds confidence intervals. The CIs can be plotted using polygons (default) or error bars.
plotci(x, y, se, level = 0.95, crit.val = NULL,
add = FALSE, col = NULL, col.ci = NULL,
alpha = NULL, bars = NULL, bw = 0.05,
linkinv = NULL, ci = NULL, ...)
x |
a vector of 'x' values ( |
y |
a vector of 'y' values ( |
se |
a vector of standard error values ( |
level |
confidence level for the intervals (between 0 and 1). |
crit.val |
an optional critical value for the intervals. If provided, the |
add |
a switch controlling whether a new plot should be created (via a call to |
col |
a character specifying the color for plotting the lines/points. |
col.ci |
a character specifying the color for plotting the intervals. |
alpha |
a scalar between 0 and 1 controlling the transparency of the intervals. |
bars |
a switch controlling whether the intervals should be plotted as bars or polygons. |
bw |
a positive scalar controlling the bar width. Ignored if |
linkinv |
an inverse link function for the plotting. If provided, the function plots |
ci |
an optional matrix if dimension |
... |
extra arguments passed to the |
This function plots x
versus y
with confidence intervals. Unless ci
is provided, the CIs have the form
lwr = y - crit.val * se
upr = y + crit.val * se
where crit.val
is the critical value.
If crit.val = NULL
, the critival value is determined from the level
input as
crit.val <- qnorm(1-(1-level)/2)
where qnorm
is the quantile function for the standard normal distribution.
Nathaniel E. Helwig <helwig@umn.edu>
This function is used by plot.ss
to plot smoothing spline fits.
# generate data
set.seed(1)
n <- 100
x <- seq(0, 1, length.out = n)
fx <- 2 + 3 * x + sin(2 * pi * x)
y <- fx + rnorm(n, sd = 0.5)
# fit smooth model
smod <- sm(y ~ x, knots = 10)
# plot fit with 95% CI polygon
plotci(x, smod$fitted.values, smod$se.fit)
# plot fit with 95% CI bars
plotci(x, smod$fitted.values, smod$se.fit, bars = TRUE)
# plot fit +/- 1 SE
plotci(x, smod$fitted.values, smod$se.fit, crit.val = 1, bars = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.