plotci: Generic X-Y Plotting with Confidence Intervals

Description Usage Arguments Details Value Author(s) Examples

Description

This is a modification to the R function plot that adds confidence intervals to the plot.

Usage

1
2
3
4
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 x and y containing the standard errors of the y values.

level

Significance level for the confidence interval. Default forms 95% interval.

cval

Critical value for the confidence interval. Default uses cval=qnorm(1-(1-level)/2).

col

Color for plotting the relationship between x and y.

col.ci

Color for plotting the confidence interval.

alpha

Transparency used for plotting confidence polygons. Only used when bars=FALSE.

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 bars=TRUE.

bw

Positive scalar giving the width of the confidence bars. Only used when bars=TRUE.

...

Additional arguments to be passed to plot (e.g., xlab, ylab, main, cex, cex.axis, cex.lab, etc.)

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
##########   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)

taylerablake/thin-plate-splines documentation built on May 8, 2019, 11:16 p.m.