78 第五章 图库 1 > # 原始数据:是否失效以及相应温度 2 > fail = factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 3 + 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1), levels = 1:2, 4 + labels = c("no", "yes")) 5 > temperature = c(53, 57, 58, 63, 66, 67, 67, 67, 68, 6 + 69, 70, 70, 70, 70, 72, 73, 75, 75, 76, 76, 78, 7 + 79, 81) 8 > par(mar = c(4, 4, 0.5, 2)) 9 > cdplot(fail ~ temperature, col = c("lightblue", "red")) 10 > # 用黄色的点表示原始数据;注意y轴位置不是c(1, 2)! 11 > # 请思考为什么(看源代码 getS3method(cdplot, default)) 12 > points(temperature, c(0.25, 0.75)[as.integer(fail)], 13 + col = "blue", bg = "yellow", pch = 21) fail no yes 55 60 65 70 75 80 temperature 图 5.10: 航天飞机O型环在不同温度下失效的条件密度图:随着温度升高, O型环越来越不容易失效。 0.0 0.2 0.4 0.6 0.8 1.0
5.7 条件密度图 79 小到大在纵轴方向上依次展示出Y = i (i = 1, 2, · · · , k)的条件概率分布比 例Pi = P (Y = i|X = x),这些比例大小沿横轴方向上以多边形表示,在任 一一个X点,所有比例之和均为1,这个性质是显而易见的: k P (Y = i|X = x) = 1; ∀x i=1 R中条件密度图的函数为cdplot(),它主要是基于密度函数density()完成 条件密度的计算(Hofmann and Theus, 2005),其用法如下: 1 > usage(cdplot, "default") cdplot(x, y, plot = TRUE, tol.ylab = 0.05, ylevels = NULL, bw = "nrd0", n = 512, from = NULL, to = NULL, col = NULL, border = 1, main = "", xlab = NULL, ylab = NULL, yaxlabels = NULL, xlim = NULL, ylim = c(0, 1), ...) 1 > usage(cdplot, "formula") cdplot(formula, data = list(), plot = TRUE, tol.ylab = 0.05, ylevels = NULL, bw = "nrd0", n = 512, from = NULL, to = NULL, col = NULL, border = 1, main = "", xlab = NULL, ylab = NULL, yaxlabels = NULL, xlim = NULL, ylim = c(0, 1), ..., subset = NULL) 函数cdplot()是泛型函数,它可以支持两种参数类型:直接输入两个数 值向量x和y或者一个公式y~x。x为条件变量X,它是一个数值向量,y是一 个因子向量,即离散变量Y ;plot为逻辑值,决定了是否作出图形(或者仅 仅是计算而不作图);ylevels给出因子的取值水平(或者分类的名称),bw、 n、from和to都将被传递给density()函数以计算密度值,请参考density()帮助 文件;col给定一个颜色向量用以代表Y 的各种取值(默认为不同深浅的灰 色);border为多边形的边线颜色;其它参数诸如标题、坐标轴范围等此处 略去。 这里我们以美国国家航空和宇宙航行局的一批O型环(O-ring,一种由 橡胶或塑料制成的平环,用作垫圈)失效数据为例,这批数据有两个变量: 温度变量和是否失效的变量。为了探索温度对O型环失效的影响,我们可以 使用诸如Logistic回归之类的统计模型去计算、分析,而这里我们用条件密 度图来展示温度的影响,如图5.10。由于因变量是一个二分类变量,图中相 应有两个多边形(带颜色的区域)分别表示是否失效,从图中我们可以清
- Page 1 and 2:
现代统计图形 谢益辉 2010
- Page 3 and 4:
• 自由软件用户往往有某
- Page 5 and 6:
目录 序言 i 代序一 . . . . .
- Page 7 and 8:
5.25 向日葵散点图 . . . . . .
- Page 9:
附录 B 作图技巧 163 B.1 添
- Page 12 and 13:
5.4 泊松分布随机数茎叶图
- Page 15 and 16:
表格 5.1 二维列联表的经典
- Page 17 and 18:
序言 代序一 代序二 作者
- Page 19:
Coefficients: Estimate Std. Error t
- Page 22 and 23:
2 第一章 历史 图 1.1: Playfai
- Page 24 and 25:
4 第一章 历史 吸到了“瘴
- Page 26 and 27:
6 第一章 历史 图 1.4: 南丁
- Page 28 and 29:
8 第一章 历史 图 1.5: Minard
- Page 30 and 31:
10 第一章 历史 总的说来,
- Page 32 and 33:
12 第二章 工具 大小,如条
- Page 34 and 35:
14 第二章 工具 Type contributo
- Page 36 and 37:
16 第二章 工具 百K的一个
- Page 38 and 39:
18 第二章 工具 其实没有必
- Page 40 and 41:
20 第二章 工具
- Page 42 and 43:
22 第三章 细节 3.1 par()函数
- Page 44 and 45:
24 第三章 细节 1:10 2 4 6 8 10
- Page 46 and 47:
26 第三章 细节 las 坐标轴
- Page 48 and 49: 28 第三章 细节 oma[2] mar[2] O
- Page 50 and 51: 30 第三章 细节 3.2 plot()及
- Page 52 and 53: 32 第三章 细节 xlim, ylim 设
- Page 54 and 55: 34 第四章 元素 4.1 颜色 默
- Page 56 and 57: 36 第四章 元素 4.1.2 颜色生
- Page 58 and 59: 38 第四章 元素 [,1] [,2] [,3]
- Page 60 and 61: 40 第四章 元素 每一类调色
- Page 62 and 63: 42 第四章 元素 1 > xx = c(1912
- Page 64 and 65: 44 第四章 元素 0 1 2 3 4 5 6 7
- Page 66 and 67: 46 第四章 元素 图2.1已经使
- Page 68 and 69: 48 第四章 元素 1 > usage(arrow
- Page 70 and 71: 50 第四章 元素 一个多边形
- Page 72 and 73: 52 第四章 元素 可以看到,
- Page 74 and 75: 54 第四章 元素 1 > par(mar = c
- Page 76 and 77: 56 第四章 元素 1 > data(Export
- Page 78 and 79: 58 第四章 元素 12 72.48 2003 U
- Page 80 and 81: 60 第五章 图库 1 > par(mfrow =
- Page 82 and 83: 62 第五章 图库 f(x) = F ′ F
- Page 84 and 85: 64 第五章 图库 1 > stem(island
- Page 86 and 87: 66 第五章 图库 对原始数据
- Page 88 and 89: 68 第五章 图库 names, plot = T
- Page 90 and 91: 70 第五章 图库 1 > par(mar = c
- Page 92 and 93: 72 第五章 图库 1 > # 用分类
- Page 94: 74 第五章 图库 1 > library(MSG
- Page 97: 5.7 条件密度图 77 R中关联
- Page 101 and 102: 5.8 等高图 81 1 > data(ChinaLife
- Page 103 and 104: 5.8 等高图 83 都必须展示在
- Page 105 and 106: 5.9 条件分割图 85 1 > par(mar
- Page 107 and 108: 5.10 一元函数曲线图 87 1 > c
- Page 109 and 110: 5.12 颜色等高图 89 1 > dotchar
- Page 111 and 112: 5.13 四瓣图 91 finite = TRUE), y
- Page 113 and 114: 5.13 四瓣图 93 表 5.1: 二维
- Page 115 and 116: 5.14 颜色图 95 C和E系的优比
- Page 117 and 118: 5.14 颜色图 97 1 > par(mar = rep
- Page 119 and 120: 5.15 矩阵图 99 1 > sines = outer
- Page 121 and 122: 5.16 马赛克图 101 1 > ftable(Ti
- Page 123 and 124: 5.17 散点图矩阵 103 较低。
- Page 125 and 126: 5.18 三维透视图 105 倍数;fon
- Page 127 and 128: 5.18 三维透视图 107 Sinc( r )
- Page 129 and 130: 5.19 因素效应图 109 1 > plot.d
- Page 131 and 132: 5.21 平滑散点图 111 1 > par(ma
- Page 133 and 134: 5.22 棘状图 113 可将图5.28放
- Page 135 and 136: 5.22 棘状图 115 离散化处理,
- Page 137 and 138: 5.23 星状图 117 1 > # 预设调
- Page 139 and 140: 5.24 带状图 119 1 > layout(matri
- Page 141 and 142: 5.25 向日葵散点图 121 1 > sun
- Page 143 and 144: 5.26 符号图 123 1 > par(mar = c(
- Page 145: 5.27 饼图 125 增长率 总人口
- Page 148 and 149:
128 第五章 图库 种以比例
- Page 150 and 151:
130 第五章 图库 1 > # 真实
- Page 152 and 153:
132 第五章 图库 信用风险
- Page 154 and 155:
134 第五章 图库 1 > library(rp
- Page 156 and 157:
136 第五章 图库 有时候与
- Page 158 and 159:
138 第五章 图库 数诸如填
- Page 160 and 161:
140 第五章 图库
- Page 162 and 163:
142 第六章 系统 8 > plot(0:1,
- Page 164 and 165:
144 第七章 模型 • 类似回
- Page 166 and 167:
146 第七章 模型 7.16.1 分类
- Page 168 and 169:
148 第八章 数据 8.2.1 一维
- Page 170 and 171:
150 附录 A 程序初步 通常我
- Page 172 and 173:
152 附录 A 程序初步 1 > # 冒
- Page 174 and 175:
154 附录 A 程序初步 [1] 1 2 3
- Page 176 and 177:
156 附录 A 程序初步 [,1] [,2]
- Page 178 and 179:
158 附录 A 程序初步 A.1.5 函
- Page 180 and 181:
160 附录 A 程序初步 [1] "inte
- Page 182 and 183:
162 附录 A 程序初步 2. 变量
- Page 184 and 185:
164 附录 B 作图技巧 1 > # 本
- Page 186 and 187:
166 附录 B 作图技巧 1 > layou
- Page 188 and 189:
168 附录 B 作图技巧 screen(n
- Page 190 and 191:
170 附录 B 作图技巧 B.3 交
- Page 192 and 193:
172 附录 B 作图技巧 1 > xx =
- Page 194 and 195:
174 附录 B 作图技巧 正的频
- Page 196 and 197:
176 附录 B 作图技巧
- Page 198 and 199:
178 附录 C 统计动画
- Page 200 and 201:
180 附录 D 本书R包 D.2 数据
- Page 202 and 203:
182 参考文献 Minka , URL http:/
- Page 204 and 205:
184 参考文献 Meyer D, Zeileis A
- Page 206 and 207:
186 参考文献 Wilkinson L (2005)
- Page 208 and 209:
188 索引 点, 27 玫瑰图, 4 直
- Page 210:
190 索引 形的一些历史,包