Math 3070 § 1. Debate Data: Name: Example

advertisement
Math 3070 § 1.
Treibergs
Debate Data:
Tabulating Two-Way Tables
Name:
Example
May 19, 2011
In this example, we consider a common data manipulation question, following Elliott’s Learning SAS in the Computer Lab, 2nd. ed., Brooks/Cole, 2000 Module 20. This data processing
task used to be done fifty years ago by collating machines, the “I. B. M. Machines,” that made
Big Blue big.
Debate coach Ronda Nielson of Skyline High School wanted to know if Granger, Hunter,
Kearns and Skyline differed in the effectiveness of debate classes in teaching valuable life skills,
at least according to opinions of debaters. A survey asked debaters to rate how their debate class
compares in teaching skills to other classes. They gave the ratings 1 =more effective, 2 =just as
effective, 3 =less effective, which were stored in the variable Compared. The task of the analyst
is to cut the data set down to the four high schools in question and to the variables School
and Compared. The number of responses in each category are counted. Some respondents
didn’t answer all the questions, so that missing values had to be omitted. Once frequencies are
available, the differences in high schools can be tested using the χ2 -test for homogeneity. The
high p-value indicates that the high schools were not significantly different in responses to the
question comparing debate to other classes.
We further illustrate how to assemble tables that give the frequency, percentages and expected
values of cells, and to display them in a way similar to how the SAS frequency procedure arranges
output.
Data File Used in this Analysis:
# Math 3070 - 1
Debate Data
May 18, 2011
# Treibergs
#
# From Elliott, Learning SAS in the Computer Lab, 2nd ed, Brooks/Cole 2000
#
# Data collected from Granite School District of Utah debate students survey
# by Ronda Nielson of Skyline HS. Questions were on debate classes.
#
# Variables
#
# Number
Survey number
# School
(1=Cottonwood, 2=Cyprus, 3=Granger, 4=Granite, 5=Hunter, 6=Kearns,
#
7=Olympus, 8=Skyline, 9=Taylorsville)
# Gender
(1=male 2=female)
# Compared
How debate compares in teaching skills
#
(1=more effective, 2=just as effective, 3=less effective)
# Argumentation Effectiveness of speech/debate in teaching
#
(1=very effective, 2=somewhat effective,3=not at all effective)
# Research
(same as Argumentation)
# Reasoning
(same as Argumentation)
# Speaking
(same as Argumentation)
Number School Gender Compared Argumentation Research Reasoning Speaking
1
6 1 1
1 1 1
1
108 7 1 1
1 1 1
2
56 3 1 1
1 1 1
1
55 8 1 1
1 2 1
1
54 8 1 1
1 2 1
1
1
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
299
298
297
296
295
294
293
292
291
290
289
288
287
286
285
284
283
282
281
280
279
317
316
315
314
300
277
278
109
251
252
8
8
8
8
8
8
8
9
9
8
8
8
8
8
8
8
8
8
8
8
8
1
1
1
1
1
1
1
1
1
1
1
1
8
1
1
1
1
1
1
1
1
1
1
1
1
1
3
3
7
7
7
1
1
1
1
1
1
1
2
2
2
1
1
1
.
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
2
1
1
2
1
2
1
2
2
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
1
1
2
1
1
1
1
2
2
1
.
1
1
1
2
1
1
1
1
1
2
1
1
1
.
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
2
1
2
2
2
1
1
1
2
2
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
.
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
253
254
255
258
319
256
257
259
260
263
264
265
266
267
268
269
270
271
272
273
274
275
276
261
262
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
32
31
30
29
28
7
7
7
7
3
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7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
1
1
2
1
2
1
1
2
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
.
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
.
1
2
1
1
2
2
1
1
1
1
1
1
3
3
2
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
.
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
.
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
.
1
4
202
201
200
199
198
197
196
195
194
193
192
320
321
191
190
189
188
187
184
183
182
181
180
179
178
177
176
175
174
173
171
170
169
168
167
166
165
164
163
162
161
343
342
341
340
339
338
337
336
335
334
333
8
8
8
8
9
9
9
9
9
9
9
8
7
9
9
9
9
9
7
9
9
9
9
9
9
9
9
9
9
.
9
.
9
9
9
3
9
9
9
9
9
6
6
6
.
6
6
6
6
6
6
6
2
1
2
2
2
1
2
1
2
1
1
1
2
2
2
2
1
1
1
1
2
1
2
1
2
1
2
1
2
2
1
1
2
2
1
2
1
1
1
1
2
1
2
2
1
2
2
1
1
1
1
2
1
1
1
1
2
2
2
2
2
2
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
1
1
1
1
2
1
1
1
1
2
1
1
1
2
1
2
1
1
1
1
1
2
1
1
1
1
1
2
2
1
1
1
2
1
1
2
1
1
1
1
2
2
1
1
2
1
1
2
2
1
.
1
1
1
1
2
1
1
1
1
.
1
1
1
2
2
1
1
2
1
1
2
1
2
2
1
1
1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
2
1
1
1
1
1
1
1
1
1
2
1
1
2
2
2
1
1
1
1
2
2
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
R Session:
R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type ’license()’ or ’licence()’ for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type ’contributors()’ for more information and
’citation()’ on how to cite R or R packages in publications.
Type ’demo()’ for some demos, ’help()’ for on-line help, or
’help.start()’ for an HTML browser interface to help.
Type ’q()’ to quit R.
[R.app GUI 1.34 (5589) i386-apple-darwin9.8.0]
>
>
>
>
# Read the data file. Note that this file uses the "." for missing data
# instead of "NA" which is standard for R.
tt <- read.table("M3074DebateData.txt",header=T,na.strings=".")
tt
Number School Gender Compared Argumentation Research Reasoning Speaking
1
1
6
1
1
1
1
1
1
2
108
7
1
1
1
1
1
2
3
56
3
1
1
1
1
1
1
4
55
8
1
1
1
2
1
1
5
54
8
1
1
1
2
1
1
6
53
8
1
1
1
1
1
1
7
52
8
1
1
1
1
1
1
8
51
8
1
2
1
1
1
1
9
50
8
1
1
1
2
1
2
10
49
8
1
1
1
1
1
1
11
48
8
1
1
2
2
2
1
12
47
8
1
1
1
1
1
1
13
46
9
2
1
1
2
1
1
14
45
9
2
2
1
2
1
1
8
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
44
43
42
41
40
39
38
37
36
35
34
33
299
298
297
296
295
294
293
292
291
290
289
288
287
286
285
284
283
282
281
280
279
317
316
315
314
300
277
278
109
251
252
253
254
255
258
319
256
257
259
260
8
8
8
8
8
8
8
8
8
8
8
8
1
1
1
1
1
1
1
1
1
1
1
1
8
1
1
1
1
1
1
1
1
1
1
1
1
1
3
3
7
7
7
7
7
7
7
3
7
7
7
7
2
1
1
1
NA
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
2
1
1
2
1
2
1
2
2
1
1
2
1
1
2
1
1
1
1
1
1
1
1
2
1
2
NA
1
2
2
1
2
2
1
1
1
1
2
1
1
1
1
2
2
1
NA
1
1
1
2
1
1
1
1
1
2
1
1
1
NA
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
NA
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
9
2
1
1
1
2
2
1
1
1
2
2
2
2
1
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
2
1
1
1
1
2
1
1
1
1
1
NA
1
2
1
1
2
1
1
1
2
2
1
1
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
261
262
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
32
31
30
29
28
27
26
25
24
23
22
21
20
12
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
3
3
3
3
9
9
9
9
3
3
3
3
3
3
3
3
3
3
7
7
7
7
7
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
1
1
2
2
2
2
1
2
2
1
1
1
1
2
1
1
2
1
1
2
1
2
1
1
1
2
1
1
2
1
1
1
2
1
1
2
2
1
2
1
1
2
1
2
1
2
1
2
1
1
1
1
1
1
1
1
2
2
1
1
2
2
2
2
1
1
1
1
1
2
1
2
2
2
2
2
2
1
1
1
1
1
1
1
2
3
2
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
2
2
1
1
2
1
1
2
1
1
1
1
1
1
2
3
1
2
1
1
1
2
1
1
1
1
1
2
1
1
2
1
2
1
1
1
1
1
1
1
1
1
2
1
10
2
1
1
1
1
2
1
1
1
1
2
1
2
1
3
2
2
1
1
2
1
1
1
1
1
2
1
3
2
1
1
1
1
2
1
1
1
3
2
1
1
1
1
2
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
2
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
2
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
13
14
15
19
18
17
16
11
10
9
8
7
6
5
4
3
2
228
227
226
225
224
223
222
221
220
219
218
215
214
217
216
213
212
211
210
209
208
207
206
205
204
203
202
201
200
199
198
197
196
195
194
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
4
5
3
3
NA
3
3
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
9
9
9
9
9
2
1
2
2
2
1
1
1
1
1
1
1
1
1
2
1
2
1
2
NA
1
2
1
2
2
2
2
1
1
2
2
1
2
1
1
2
2
1
1
1
1
1
1
2
1
2
2
2
1
2
1
2
1
1
2
2
1
1
1
1
1
2
1
2
1
1
2
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
1
1
1
2
2
2
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
2
1
1
1
1
1
2
11
1
1
3
3
2
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
NA
1
2
1
2
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
2
1
1
2
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
NA
1
1
1
2
1
1
2
1
1
1
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
193
192
320
321
191
190
189
188
187
184
183
182
181
180
179
178
177
176
175
174
173
171
170
169
168
167
166
165
164
163
162
161
343
342
341
340
339
338
337
336
335
334
333
332
331
330
329
328
327
326
325
344
9
9
8
7
9
9
9
9
9
7
9
9
9
9
9
9
9
9
9
9
NA
9
NA
9
9
9
3
9
9
9
9
9
6
6
6
NA
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
1
1
1
2
2
2
2
1
1
1
1
2
1
2
1
2
1
2
1
2
2
1
1
2
2
1
2
1
1
1
1
2
1
2
2
1
2
2
1
1
1
1
2
2
2
1
2
2
1
1
1
1
2
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
2
1
1
1
1
2
1
1
1
1
2
1
1
1
2
1
2
1
1
1
1
2
1
2
1
1
1
1
2
2
1
1
1
2
1
1
2
1
1
1
1
2
2
1
1
2
1
1
2
2
1
NA
1
1
1
1
2
1
1
1
1
NA
1
1
1
2
2
1
1
2
1
1
NA
2
1
1
1
NA
1
1
2
12
2
1
1
1
2
2
1
2
2
1
1
2
NA
1
2
1
2
2
1
1
1
1
NA
1
1
2
1
1
2
1
1
1
NA
2
1
1
2
1
1
2
1
2
1
NA
1
1
2
2
NA
1
1
2
1
1
1
1
2
1
2
1
1
1
1
1
2
2
1
1
1
1
1
2
1
1
1
1
1
1
1
2
2
1
1
1
NA
1
1
1
2
1
1
1
1
1
1
NA
2
1
2
1
NA
1
1
1
1
1
1
1
3
2
1
1
1
1
1
1
2
2
1
1
2
1
1
2
1
1
1
1
1
1
1
1
NA
1
1
1
NA
1
1
1
1
1
1
1
1
1
1
NA
1
1
2
1
NA
1
1
2
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
324
322
323
160
345
159
158
157
156
155
154
153
152
143
142
151
150
149
148
147
146
145
144
141
140
139
138
137
136
135
134
133
132
131
130
129
128
127
126
125
124
68
67
66
65
64
63
62
61
60
59
58
6
6
6
7
6
7
9
9
9
8
8
8
8
7
7
8
8
8
8
8
9
9
9
7
7
7
7
7
7
7
7
NA
NA
NA
9
9
9
9
9
NA
7
6
6
6
6
5
NA
6
6
6
5
6
1
1
2
1
1
1
2
2
1
1
2
1
1
2
1
1
1
1
1
1
2
1
2
1
1
2
1
1
1
1
1
2
1
2
1
2
1
2
1
2
2
1
1
2
1
2
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
2
1
2
2
1
1
1
2
1
2
2
1
2
1
1
3
2
2
2
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
NA
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
13
1
2
2
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
NA
1
1
3
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
2
1
1
NA
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
NA
1
1
1
NA
1
1
2
3
2
1
2
1
1
1
1
NA
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
1
1
1
1
1
1
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
57
123
122
121
120
119
118
117
116
115
114
113
112
111
110
107
106
105
104
103
102
101
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
6
7
7
7
7
7
7
7
NA
7
7
7
7
7
7
7
7
7
8
8
8
8
8
8
7
7
5
5
5
5
5
5
5
5
5
5
5
NA
5
5
5
5
5
5
5
5
6
5
5
5
6
6
2
2
1
2
2
2
1
1
NA
2
2
2
2
2
2
1
2
2
2
2
1
2
2
1
1
1
2
1
2
1
1
2
1
1
1
2
1
1
1
1
2
NA
2
1
1
1
2
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
2
2
1
1
1
2
1
1
1
1
1
1
1
1
14
1
1
2
1
1
1
1
2
1
1
1
1
1
1
2
1
1
1
1
NA
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
3
2
2
3
3
1
2
1
2
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
1
1
1
1
NA
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
NA
1
1
1
1
1
1
1
1
1
NA
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
2
1
1
1
1
327
69
6
2
1
1
1
1
1
> # we can check the variables available.
> names(tt)
[1] "Number"
"School"
"Gender"
"Compared"
"Argumentation"
"Research"
[7]
"Reasoning"
"Speaking"
>
> ############## CUT THE DATA FRAME TO FOUR HIGH SCHOOLS AND NO NA’S ###############
> # We use the subsetting command. The logical condition includes the desired HS and
> # excludes NA’s. select= picks the two desired columns "School" and "Compared".
>
> tt2 <- subset(tt,(School==3 | School==5 | School==6 | School==8 ) &
+ !(is.na(School) | is.na(Compared)),select=c(2,4))
> tt2
School Compared
1
6
1
3
3
1
4
8
1
5
8
1
6
8
1
7
8
1
8
8
2
9
8
1
10
8
1
11
8
1
12
8
1
15
8
2
16
8
1
17
8
1
18
8
1
19
8
1
20
8
2
21
8
1
22
8
1
23
8
1
24
8
1
25
8
2
26
8
2
39
8
1
53
3
1
54
3
1
62
3
1
83
3
1
84
3
1
85
3
1
86
3
1
91
3
2
92
3
2
93
3
2
94
3
2
95
3
2
96
3
1
97
3
1
15
98
99
100
135
136
137
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
160
161
162
163
164
165
173
197
203
204
205
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
3
3
3
5
3
3
3
3
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
3
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
2
1
2
1
1
1
1
2
1
2
1
1
1
1
16
222
223
224
225
227
232
233
234
235
238
239
240
241
242
264
265
266
267
268
270
271
272
273
274
275
293
294
295
296
297
298
301
302
303
304
305
306
307
308
309
310
311
313
314
315
316
317
318
319
320
321
322
6
6
6
6
6
8
8
8
8
8
8
8
8
8
6
6
6
6
5
6
6
6
5
6
6
8
8
8
8
8
8
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
6
5
2
1
1
1
1
1
1
2
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
17
323
5
2
324
5
1
325
6
1
326
6
1
327
6
1
>
> # Now make the subset available locally.
> attach(tt2)
>
> ############################ DO THE CELL COUNTS #############################
>
> tb1 <- table(tt2) ; tb1
Compared
School 1 2
3 17 6
5 22 3
6 30 7
8 55 7
>
> # ROW TOTALS AND COLUMN TOTALS
>
> rowsum <- margin.table(tb1,1); rowsum
School
3 5 6 8
23 25 37 62
> colsum <- margin.table(tb1,2); colsum
Compared
1
2
124 23
>
> # To add row and column sums to the table we can column-bind the vector of
> # rowsums, sum the columns and row-bind it to the table.
>
> tb2 <- cbind(tb1,rowsum);tb2
1 2 rowsum
3 17 6
23
5 22 3
25
6 30 7
37
8 55 7
62
> columnsum <- margin.table(tb2,2)
> rbind(tb2,columnsum)
1 2 rowsum
3
17 6
23
5
22 3
25
6
30 7
37
8
55 7
62
columnsum 124 23
147
18
>
>
>
>
>
>
>
>
>
>
>
######################### EXPECTED VALUE AND PERCENTAGES OF CELLS ##################
#
#
#
#
Let total = sum of all celle = number of valid observations.
If p[i] = sum row i / total and q[j] = sum col j / total are the
row and column percentages then the expected number in the [i,j] cell is
ex[i,j] = p[i] * q[j] * total = row[i] sum * col[j] sum / total.
# A %o% B is "outer product" is the matrix whose [i,j] entry is A[i]B[j].
# It gives expected * total.
ex <- ( rowsum %o% colsum )/ sum(tb1) ; ex
Compared
School
1
2
3 19.40136 3.598639
5 21.08844 3.911565
6 31.21088 5.789116
8 52.29932 9.700680
>
> # Compute what the cell is as a percent of the whole table.
>
> pct <- 100* tb1 / sum(tb1) ; pct
Compared
School
1
2
3 11.564626 4.081633
5 14.965986 2.040816
6 20.408163 4.761905
8 37.414966 4.761905
>
> # Compute what the cell is as a percent of its row.
>
> rowpct <- 100* prop.table(tb1,1) ; rowpct
Compared
School
1
2
3 73.91304 26.08696
5 88.00000 12.00000
6 81.08108 18.91892
8 88.70968 11.29032
>
> # Compute what the cell is as a percent of its column.
>
> colpct <- 100* prop.table(tb1,2) ; colpct
Compared
School
1
2
3 13.70968 26.08696
5 17.74194 13.04348
6 24.19355 30.43478
8 44.35484 30.43478
19
>################### MAKE A SAS STYLE TABLE INCLUDING EX AND PCTS ####################
>
> # One learns that anything is possible in R. The student just has to be tough enough
> # to figure things out by themselves. There are several ways to so this.
> # I concluded that it is easiest just to make a data frame with the numbers (val)
> # viewed as a single vector and with School, Compared and vv (the statistic) as
> # factors. I’m sure one of you will show me an easier way!
>
> compared <- factor(rep(rep(1:2,c(4,4)),5)); compared
[1] 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2
Levels: 1 2
>
> school <- factor(rep(c(3,5,6,8),10)); school
[1] 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8 3 5 6 8
Levels: 3 5 6 8
>
> vv <- factor(rep(1:5,rep(8,5))) ; vv
[1] 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5
Levels: 1 2 3 4 5
>
> val <-c(tb1,ex,pct,rowpct,colpct) ; val
[1] 17.000000 22.000000 30.000000 55.000000 6.000000 3.000000 7.000000 7.000000
[9] 19.401361 21.088435 31.210884 52.299320 3.598639 3.911565 5.789116 9.700680
[17] 11.564626 14.965986 20.408163 37.414966 4.081633 2.040816 4.761905 4.761905
[25] 73.913043 88.000000 81.081081 88.709677 26.086957 12.000000 18.918919 11.290323
[33] 13.709677 17.741935 24.193548 44.354839 26.086957 13.043478 30.434783 30.434783
> sast <- data.frame(school,compared,vv,val); sast
school compared vv
val
1
3
1 1 17.000000
2
5
1 1 22.000000
3
6
1 1 30.000000
4
8
1 1 55.000000
5
3
2 1 6.000000
6
5
2 1 3.000000
7
6
2 1 7.000000
8
8
2 1 7.000000
9
3
1 2 19.401361
10
5
1 2 21.088435
11
6
1 2 31.210884
12
8
1 2 52.299320
13
3
2 2 3.598639
14
5
2 2 3.911565
15
6
2 2 5.789116
16
8
2 2 9.700680
17
3
1 3 11.564626
18
5
1 3 14.965986
19
6
1 3 20.408163
20
8
1 3 37.414966
21
3
2 3 4.081633
22
5
2 3 2.040816
23
6
2 3 4.761905
24
8
2 3 4.761905
20
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
3
5
6
8
3
5
6
8
3
5
6
8
3
5
6
8
1
1
1
1
2
2
2
2
1
1
1
1
2
2
2
2
4
4
4
4
4
4
4
4
5
5
5
5
5
5
5
5
73.913043
88.000000
81.081081
88.709677
26.086957
12.000000
18.918919
11.290323
13.709677
17.741935
24.193548
44.354839
26.086957
13.043478
30.434783
30.434783
21
>
>
>
>
,
# Give meaningful names to the statisics, the levels of factor vv.
levels(vv) <- c("Frequency","Expected","Percent","Row Pct","Col Pct")
xtabs(val ~ vv
, school = 3
+ compared + school)
compared
vv
Frequency
Expected
Percent
Row Pct
Col Pct
1
2
17.000000 6.000000
19.401361 3.598639
11.564626 4.081633
73.913043 26.086957
13.709677 26.086957
, , school = 5
compared
vv
Frequency
Expected
Percent
Row Pct
Col Pct
1
2
22.000000 3.000000
21.088435 3.911565
14.965986 2.040816
88.000000 12.000000
17.741935 13.043478
, , school = 6
compared
vv
Frequency
Expected
Percent
Row Pct
Col Pct
1
2
30.000000 7.000000
31.210884 5.789116
20.408163 4.761905
81.081081 18.918919
24.193548 30.434783
, , school = 8
compared
vv
Frequency
Expected
Percent
Row Pct
Col Pct
1
2
55.000000 7.000000
52.299320 9.700680
37.414966 4.761905
88.709677 11.290323
44.354839 30.434783
22
>########################### CHI-SQUARED TEST FOR HOMOGENEITY #################
>
> tb1
Compared
School 1 2
3 17 6
5 22 3
6 30 7
8 55 7
>
>
> chisq.test(tb1)
Pearson’s Chi-squared test
data: tb1
X-squared = 3.3431, df = 3, p-value = 0.3417
Warning message:
In chisq.test(tb1) : Chi-squared approximation may be incorrect
>
23
Download