# [R] Prediction Intervals (reposting)

Ronnen Levinson RML27 at cornell.edu
Sat Aug 16 19:34:59 CEST 2003

```(I'm reposting this message because the original has not appeared after
about 2 days. Sorry if it shows up twice.)

Hello.

First, thanks to those who responded to my recent inquiry about using
contour() over arbitrary (x,y) by mentioning the interp() function in
the akima package. That worked nicely. Now for a new question:

I would like to use a pair of prediction intervals to graphically bound
the noise in some y(x) measurements. Here's an artificial example
showing a function y(x)=x + noise, where the noise diminishes as x
increases from 0 to 1.

x=seq(0,1,0.01)
y=x+runif(length(x),-1,1)*((1-x)/5)
fit=lm(y ~ 1 + x)
pred=predict(fit, interval="prediction")
matplot(x,pred,type="l",ylab="y")
points(x,y)

I would have expected the lower and upper prediction intervals to
converge as x increases (and the noise decreases), but they seem to
remain virtually equidistant. Can anyone explain (a) the behavior that I
see, and (b) how to obtain curves that do bound the noise?

Thanks,

Ronnen.

--
Ronnen Levinson, Ph.D.            \/      RML27 at cornell.edu
scientist                         ||      http://ronnen.com
Lawrence Berkeley National Lab    /\      fax 425.955.1992

======================================
I took a speed reading course and read 'War and Peace' in twenty minutes. It involves Russia.
-- Woody Allen

```