bandplot.html
3.62 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>R: Plot x-y Points with Locally Smoothed Mean and Standard Deviation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for bandplot {gplots}"><tr><td>bandplot {gplots}</td><td align="right">R Documentation</td></tr></table>
<h2>Plot x-y Points with Locally Smoothed Mean and Standard Deviation</h2>
<h3>Description</h3>
<p>
Plot x-y Points with lines showing the locally smoothed mean and
standard deviation.
</p>
<h3>Usage</h3>
<pre>
bandplot(x, y, ..., add = FALSE, sd = c(-2:2),
sd.col = c("lightblue", "blue", "red", "blue", "lightblue"),
method = "frac", width = 1/5, n=50)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
numeric vector of x locations</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>
numeric vector of x locations</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
Additional plotting parameters. </td></tr>
<tr valign="top"><td><code>add</code></td>
<td>
Boolean indicating whether the local mean and standard
deviation lines should be added to an existing plot. Defaults to
FALSE.</td></tr>
<tr valign="top"><td><code>sd</code></td>
<td>
Vector of multiples of the standard devation that should be
plotted. <code>0</code> gives the mean, <code>-1</code> gives the mean minus
one standard deviation, etc. Defaults to -2:2.</td></tr>
<tr valign="top"><td><code>sd.col</code></td>
<td>
Color of each plotted line.</td></tr>
<tr valign="top"><td><code>method, width, n</code></td>
<td>
Parameters controlling the smoothing. See the
help page for <code><a href="wapply.html">wapply</a></code> for details.</td></tr>
</table>
<h3>Details</h3>
<p>
<code>bandplot</code> was created to look for changes in the mean or
variance of scatter plots, particularly plots of regression residuals.
</p>
<p>
The local mean and standard deviation are calculated by calling
'wapply'. By default, bandplot asks wapply to smooth using intervals
that include the nearest 1/5 of the data. See the documentation of
that function for details on the algorithm.
</p>
<h3>Value</h3>
<p>
Invisibly returns a list containing the x,y points plotted for each line.</p>
<h3>Author(s)</h3>
<p>
Gregory R. Warnes <a href="mailto:warnes@bst.rochester.edu">warnes@bst.rochester.edu</a>
</p>
<h3>See Also</h3>
<p>
<code><a href="wapply.html">wapply</a></code>, <code><a href="lowess.html">lowess</a></code>
</p>
<h3>Examples</h3>
<pre>
# fixed mean, changing variance
x <- 1:1000
y <- rnorm(1000, mean=1, sd=1 + x/1000 )
bandplot(x,y)
# fixed varance, changing mean
x <- 1:1000
y <- rnorm(1000, mean=x/1000, sd=1)
bandplot(x,y)
#
# changing mean and variance
#
x <- abs(rnorm(500))
y <- rnorm(500, mean=2*x, sd=2+2*x)
# the changing mean and dispersion are hard to see whith the points alone:
plot(x,y )
# regression picks up the mean trend, but not the change in variance
reg <- lm(y~x)
summary(reg)
# using bandplot on the original data helps to show the mean and
# variance trend
bandplot(x,y)
# using bandplot on the residuals helps to see that regression removes
# the mean trend but leaves the trend in variability
bandplot(predict(reg),resid(reg))
</pre>
<hr><div align="center">[Package <em>gplots</em> version 2.3.2 <a href="00Index.html">Index]</a></div>
</body></html>