找回密码
 立即注册
查看: 2573|回复: 0

Two-Way Analysis of Variance Statistical Tests and Graphics Using R

[复制链接]
发表于 2013-2-15 00:00:41 | 显示全部楼层 |阅读模式
Two-Way Analysis of Variance Statistical Tests and Graphics Using R
目录
1 Learn R with Sample Lessons in Education and the Social
Sciences, Health, and the Biological Sciences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Purpose of These Lessons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Background on R. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Background on Two-Way ANOVA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Organization of These Lessons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.1 Data Import or Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.2 Data Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.3 Display the Code Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.4 Conduct a Visual Data Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.5 Descriptive Analysis of the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5 Details of the Three Sample Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5.1 Tab-Separated ASCII File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5.2 FixedWidth–Fixed Column ASCII File . . . . . . . . . . . . . . . . . . . . . 6
1.5.3 Comma-Separated Values ASCII File . . . . . . . . . . . . . . . . . . . . . . . . 6
2 Two-Way Analysis of Variance (ANOVA) Sample 1:
Comparison of Scores on a Final Examination by Teaching
Method and by Status as a Community College Graduate .. . . . . . . . . . . . . 9
2.1 Data Import of a .txt Tab-Delimited Data File into R . . . . . . . . . . . . . . . . . 10
2.1.1 Data Import or Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Organize the Data and Display the Code Book . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Conduct a Visual Data Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.1 Simple Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.3.2 Histogram of the Summary Object Variable . . . . . . . . . . . . . . . . . 16
2.3.3 Horizontal and Vertical Boxplots
of the Summary Object Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.4 Sorted Dot Chart of the Summary Object
Variable by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.5 Histogram of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
v
vi Contents
2.4 Descriptive Analysis of the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4.1 Summary Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4.2 Breakout Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5 Use R for Two-Way Analysis of Variance (ANOVA) . . . . . . . . . . . . . . . . . 25
2.5.1 Two-Way ANOVA: aov() Function . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5.2 Outcome to Sample 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3 Two-Way Analysis of Variance (ANOVA) Sample 2:
Comparison of Systolic Blood Pressure Readings by
Self-Declared Smoking Habits and by Self-Declared
Drinking Habits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.1 Data Import of a .prn Fixed Width–Fixed Column
(e.g., Space-Separated) Format Data File into R . . . . . . . . . . . . . . . . . . . . . . 33
3.1.1 Data Import or Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.2 Organize the Data and Display the Code Book . . . . . . . . . . . . . . . . . . . . . . . . 37
3.3 Conduct a Visual Data Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.3.1 Simple Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.3.2 Histogram of the Summary Object Variable . . . . . . . . . . . . . . . . . 45
3.3.3 Horizontal and Vertical Boxplots of the
Summary Object Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.3.4 Histogram of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.3.5 Density Plot of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.3.6 Boxplot of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.4 Descriptive Analysis of the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.4.1 Summary Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.4.2 Breakout Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.5 Use R for Two-Way Analysis of Variance (ANOVA) . . . . . . . . . . . . . . . . . 60
3.5.1 Two-Way ANOVA: aov() Function . . . . . . . . . . . . . . . . . . . . . . . . 60
3.5.2 s20x Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.5.3 Outcome to Sample 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4 Two-Way Analysis of Variance (ANOVA) Sample 3:
Comparison of Larvae Counts by AgChem Formulation
and by AgChem Application Time-of-Day .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.1 Data Import of a .csv Spreadsheet-Type Data File into R. . . . . . . . . . . . . 71
4.1.1 Data Import or Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.2 Organize the Data and Display the Code Book . . . . . . . . . . . . . . . . . . . . . . . . 72
4.3 Conduct a Visual Data Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.3.1 Simple Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.3.2 Histogram of the Summary Object Variable . . . . . . . . . . . . . . . . . 79
4.3.3 Horizontal and Vertical Boxplots
of the Summary Object Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
4.3.4 Violin Plot of the Summary Object Variable .. . . . . . . . . . . . . . . . 86
Contents vii
4.3.5 Beanplot of the Summary Object Variable .. . . . . . . . . . . . . . . . . . 88
4.3.6 Quantile–Quantile (Q–Q) Plot of the Summary
Object Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.3.7 Sorted Dot Chart of the Summary Object
Variable by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . 90
4.3.8 Histogram of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.3.9 Density Plot of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4.3.10 Boxplot of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
4.3.11 Horizontal and Vertical Boxplots of the Summary
Object Variable by Breakout Object Variables . . . . . . . . . . . . . . . 98
4.3.12 Vertical Violin Plots of the Summary Object
Variable by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . 100
4.3.13 Beanplots of the Summary Object Variable
by Breakout Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
4.3.14 Representation of Group Means and Confidence Intervals .. 103
4.3.15 Plot Breakout Object Values on a Continuum
of the Summary Object Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
4.4 Descriptive Analysis of the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4.4.1 Summary Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4.4.2 Breakout Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
4.4.3 Contingency Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
4.5 Use R for Two-Way Analysis of Variance (ANOVA) . . . . . . . . . . . . . . . . . 126
4.5.1 Two-Way ANOVA: aov() Function . . . . . . . . . . . . . . . . . . . . . . . . 126
4.5.2 Additional R Packages that Support Two-Way ANOVA . . . . 128
4.5.3 Outcome to Sample 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4.5.4 Consideration of the Data from a Nonparametric
Perspective .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
4.5.5 Optional Housekeeping at End-of-Session .. . . . . . . . . . . . . . . . . . 137

下载:
Two-Way Analysis of Variance Statistical Tests and Graphics Using R.rar (1.38 MB, 下载次数: 1, 售价: 5 )

备注:
很多人都有收集一堆资料而不看的习惯。为了有效利用资源,养成下载一本看一本的习惯,特设置了积分下载,请见谅。
多参加论坛的活动、多帮助别人,会很容易凑够积分的!
祝大家使用愉快!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|R语言中文网

GMT+8, 2024-11-25 01:26 , Processed in 0.023735 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表