plotci {bigsplines} | R Documentation |
Generic X-Y Plotting with Confidence Intervals
Description
This is a modification to the R function plot
that adds confidence intervals to the plot.
Usage
plotci(x, y, se, level=0.95, cval=NULL, col="blue",
col.ci="cyan", alpha=0.65, add=FALSE,
type="l", link=function(y){y}, axes=TRUE,
bars=FALSE, barlty=1, barlwd=2, bw=0.2, ...)
Arguments
x , y |
The x and y coordinates of the points to plot. |
se |
Numeric vector the same length as |
level |
Significance level for the confidence interval. Default forms 95% interval. |
cval |
Critical value for the confidence interval. Default uses |
col |
Color for plotting the relationship between |
col.ci |
Color for plotting the confidence interval. |
alpha |
Transparency used for plotting confidence polygons. Only used when |
add |
Logical indicating whether lines should be added to current plot. |
type |
Type of plot to create (defaults to "l" for lines). |
link |
Link function to apply. See Details. |
axes |
Logical indicating if the axes should be drawn. |
bars |
Logical indicating if confidence bars should be plotted instead of polygons. |
barlty , barlwd |
Line type and width for confidence bars. Only used when |
bw |
Positive scalar giving the width of the confidence bars. Only used when |
... |
Additional arguments to be passed to |
Details
The plotted confidence interval is c(link(y-cval*se), link(y+cval*se))
where link
is the user-specified link function and cval
is the user-sepcified critival value, which defaults to cval = qnorm(1-(1-level)/2)
.
Value
Produces a plot
with a colorbar.
Author(s)
Nathaniel E. Helwig <helwig@umn.edu>
Examples
########## EXAMPLE ##########
# define relatively smooth function
set.seed(773)
myfun <- function(x){ sin(2*pi*x) }
x <- runif(10^4)
y <- myfun(x) + rnorm(10^4)
# fit cubic smoothing spline
cubmod <- bigspline(x,y)
newdata <- data.frame(x=seq(0,1,length=20))
ypred <- predict(cubmod, newdata, se.fit=TRUE)
# plot predictions with CIs in two ways
plotci(newdata$x, ypred$fit, ypred$se.fit)
plotci(newdata$x, ypred$fit, ypred$se.fit, type="p", bars=TRUE, bw=0.02)