Description Usage Arguments Value Author(s) See Also Examples
Produce a linear, quadratic, or nonparametric tube for regression data.
1 2 3 |
x |
|
y |
|
Z |
Number of standard deviations out from the regression line to extend the tube. |
R |
Control of how far the tube extends to the left and right. |
col |
Fill color of the tube. |
border |
Border color of the tube. |
type |
The type of model fit to the data. Here |
stDev |
Choices are constant variance ( |
length.out |
The number of observations used to build the regression model. This argument may be increased to increase the smoothing of a quadratic or nonparametric curve. |
bw |
Bandwidth used if |
plotTube |
Whether the tube should be plotted. |
addLine |
Whether the linear model should be plotted. |
... |
Additional arguments passed to the |
X |
|
Y |
|
tubeX |
|
tubeY |
|
David M Diez
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #===> possum example <===#
data(possum)
x <- possum$totalL
y <- possum$headL
plot(x,y)
makeTube(x,y,1)
makeTube(x,y,2)
makeTube(x,y,3)
#===> Grades and TV example <===#
data(gradesTV)
par(mfrow=c(2,2))
plot(gradesTV)
makeTube(gradesTV$TV, gradesTV$Grades, 1.5)
plot(gradesTV)
makeTube(gradesTV$TV, gradesTV$Grades, 1.5, stDev='o')
plot(gradesTV)
makeTube(gradesTV$TV, gradesTV$Grades, 1.5, type='robust')
plot(gradesTV)
makeTube(gradesTV$TV, gradesTV$Grades, 1.5, type='robust', stDev='o')
#===> What can go wrong with a basic least squares model <===#
par(mfrow=c(1,3), mar=c(2.5, 2.5, 1, 2.5))
# 1
x <- runif(100)
y <- 25*x-20*x^2+rnorm(length(x), sd=1.5)
plot(x,y)
makeTube(x,y,type='q')
# 2
x <- c(-0.6, -0.46, -0.091, runif(97))
y <- 25*x + rnorm(length(x))
y[2] <- y[2] + 8
y[1] <- y[1] + 1
plot(x,y,ylim=range(y)+c(-10,5))
makeTube(x,y)
# 3
x <- runif(100)
y <- 5*x + rnorm(length(x), sd=x)
plot(x,y)
makeTube(x, y, stDev='l', bw=0.03)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.