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
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
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
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
**********************************************************************
*** Reproducing one-way ANOVA Tables
*** Valentim R. Alferes (University of Coimbra, Portugal)
*** valferes@fpce.uc.pt

** This syntax reproduces traditional one-way ANOVA Tables 
** from summary statistics in published articles.

** You have four methods, depending on the available data.

**********************************************************************

** METHOD 1: Ns Means, and SDs.

* Enter, row by row, N, Mean and Standard Deviation for the 
* groups or experimental treatments (in the example, you have
* three treatments).

DATA LIST LIST /n(F8.0) m(f8.2) sd(f8.2).
BEGIN DATA
6  10,50  2,30
7  11,34  3,60
8  15,17  4,10
END DATA.

COMPUTE iv=$CASENUM.
LOOP id=1 TO n.
XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE dv=m.
COMPUTE k=SQR((sd**2*(N-1))/2).
IF (id=1) dv=m+k.
IF (id=2) dv=m-k.
EXECUTE.
SUMMARIZE/TABLES=dv BY iv/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN STDDEV VAR.
ONEWAY dv BY iv.

**********************************************************************

** METHOD 2: Ns Means, and Variances.

* Enter, row by row, N, Mean and Variance for the 
* groups or experimental treatments (in the example, you have
* three treatments).

DATA LIST LIST /n(F8.0) m(f8.2) var(f8.2).
BEGIN DATA
6  10,50  5,29
7  11,34  12,96
8  15,17  16,81
END DATA.

COMPUTE iv=$CASENUM.
LOOP id=1 TO n.
XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE dv=m.
COMPUTE k=SQR((var*(N-1))/2).
IF (id=1) dv=m+k.
IF (id=2) dv=m-k.
EXECUTE.
SUMMARIZE/TABLES=dv BY iv/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN STDDEV VAR.
ONEWAY dv BY iv.


**********************************************************************

** METHOD 3: Ns, Means, and MSError.

* Enter, row by row, N and Mean for the groups or experimental
* treatments (in the example, you have three treatments).

DATA LIST LIST /n(F8.0) m(f8.0).
BEGIN DATA
6  10,50
7  11,34
8  15,17
END DATA.

* Enter Mean Square Error.
COMPUTE mse = 12.32667.

COMPUTE iv=$CASENUM.
LOOP id=1 TO n.
XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE dv=m.
COMPUTE k=SQR((mse*(N-1))/2).
IF (id=1) dv=m+k.
IF (id=2) dv=m-k.
EXECUTE.
SUMMARIZE/TABLES=dv BY iv/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN.
ONEWAY dv BY iv.

**********************************************************************

** METHOD 4: Means, DFnum, DFden, and MSError.

* Enter, row by row, the Mean for the groups or experimental
* treatments (in the example, you have three treatments).

DATA LIST LIST /m(f8.2).
BEGIN DATA
10,50
11,34
15,17  
END DATA.

* Enter degrees of freedom for numerator (between groups df).
COMPUTE dfnum=2.

* Enter degrees of freedom for denominator (within groups 
* or MSError df).
COMPUTE dfden=18.

* Enter MSError.
COMPUTE mse=12.32667.

COMPUTE iv=$CASENUM.
COMPUTE n_tot=dfnum+dfden+1.
COMPUTE n_treat=dfnum+1.
COMPUTE nxi=RND(n_tot/n_treat).
EXECUTE.
CREATE cum=CSUM(nxi).
SORT CASES BY cum(D).
IF ($CASENUM=1) nxi=nxi-(cum-n_tot).
EXECUTE.
SORT CASES BY iv(A).
LOOP id=1 TO nxi.
XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE dv=m.
COMPUTE k=SQR((mse*(nxi-1))/2).
IF (id=1) dv=m+K.
IF (id=2) dv=m-K.
EXECUTE.
SUMMARIZE/TABLES=dv BY iv/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN.
ONEWAY dv BY iv.

**********************************************************************
** Note
** With Method 4 you don't know the Ns per treatment from the original
** source. If they are equal, you will get the exact ANOVA Table. Otherwise,
** as is the case in this example, you get only an approximation, 
** because the syntax assumes that the Ns are equal in all treatments
** (if N_TOT/N_TREAT is an integer), or that they are equal in all 
** treatments, except for the last one (if N_TOT/N_TREAT is not an integer).
**
** The syntax bellow exemplifies the case for equal Ns per treatment.

**********************************************************************

** The following syntax does the ANOVA on raw data from Kirk 
**(1995, p. 167, Table 5.2-I) and compares it with Methods 1 and 4.

** Analysis of raw data from Kirk (1995, p. 167, Table 5.2-I).

DATA LIST FREE /IV(F8.0) DV(F8.0).
BEGIN DATA
1 4 1 6 1 3 1 3 1 1 1 3 1 2 1 2 2 4 2 5 2 4 2 3 2 2 2 3 2 4 2 3 3 5 
3 6 3 5 3 4 3 3 3 4 3 3 3 4 4 3 4 5 4 6 4 5 4 6 4 7 4 8 4 10 
END DATA.
ONEWAY dv BY iv/STATISTICS DESCRIPTIVES.

** METHOD 1: Ns Means, and SDs.

* Enter, row by row, N, Mean and Standard Deviation for the 
* groups or experimental treatments (in the example, you have
* three treatments).

DATA LIST LIST /n(F8.0) m(f8.2) sd(f8.6).
BEGIN DATA
8  3,00  1,511858
8  3,50  0,925820
8  4,25  1,035098
8  6,25  2,121320
END DATA.

COMPUTE iv=$CASENUM.
LOOP id=1 TO n.
XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE dv=m.
COMPUTE k=SQR((sd**2*(N-1))/2).
IF (id=1) dv=m+k.
IF (id=2) dv=m-k.
EXECUTE.
SUMMARIZE/TABLES=dv BY iv/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN STDDEV VAR.
ONEWAY dv BY iv.

** METHOD 4: Means, DFnum, DFden, and MSError.

* Enter, row by row, the Mean for the groups or experimental
* treatments (in the example, you have three treatments).

DATA LIST LIST /m(f8.2).
BEGIN DATA
3,00
3,50
4,25
6,25
END DATA.

* Enter degrees of freedom for numerator (between groups df).
COMPUTE dfnum=3.

* Enter degrees of freedom for denominator (within groups 
* or MSError df).
COMPUTE dfden=28.

* Enter MSError.
COMPUTE mse=2.178571.

COMPUTE iv=$CASENUM.
COMPUTE n_tot=dfnum+dfden+1.
COMPUTE n_treat=dfnum+1.
COMPUTE nxi=RND(n_tot/n_treat).
EXECUTE.
CREATE cum=CSUM(nxi).
SORT CASES BY cum(D).
IF ($CASENUM=1) nxi=nxi-(cum-n_tot).
EXECUTE.
SORT CASES BY iv(A).
LOOP id=1 TO nxi.
XSAVE OUTFILE=XOUT1.
END LOOP.
EXECUTE.
GET FILE=XOUT1.
COMPUTE dv=m.
COMPUTE k=SQR((mse*(nxi-1))/2).
IF (id=1) dv=m+K.
IF (id=2) dv=m-K.
EXECUTE.
SUMMARIZE/TABLES=dv BY iv/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN.
ONEWAY dv BY iv.

**********************************************************************
Kirk, R. E. (1995). Experimental design: Procedures for the behavioral
 sciences (3rd ed.). Pacific Grove, CA: Brooks/Cole.
**********************************************************************.