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
**********************************************************************
*** Factorial ANOVA: Measures of Association, Effect Size and
*** Observed Power
*** Valentim R. Alferes (University of Coimbra, Portugal)
*** valferes@fpce.uc.pt

** This syntax does an A*B Factorial ANOVA and calculates:
** - variance components;
** - measures of association (squared etas and partial squared 
**   etas; squared omegas and partial squared omegas);
** - measures of effect size (Cohen's f);
** - observed power.

** The user has two methods: Analysing raw data or reproducing 
** the ANOVA Table from summary statistics in published articles.

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

** METHOD 1: Analysing raw data

** The data have to be in a SPSS active file with the following 
** three numeric variables:
** A – Factor A or IV1;
** B – Factor B or IV2;
** DV – Dependent variable

** The following lines create an active file with an example
** from Keppel (1991, p. 214, Table 10-6).

DATA LIST FREE /A(F8.0) B(F8.0) DV(F8.0).
BEGIN DATA
1 1 1 1 1 4 1 1 0 1 1 7 2 1 13 2 1 5 2 1 7 2 1 15 3 1 9 3 1 16 3 1 18 
3 1 13 1 2 15 1 2 6 1 2 10 1 2 13 2 2 6 2 2 18 2 2 9 2 2 15 3 2 14 3 
2 7 3 2 6 3 2 13 
END DATA.


* Enter alpha for calculating power(by default, alpha = .05).
UNIANOVA DV BY A B/PRINT=DESCRIPTIVE ETASQ OPOWER/CRITERIA=ALPHA(.05)
/EMMEANS=TABLES(OVERALL)/EMMEANS=TABLES(A)/EMMEANS=TABLES(B)
/EMMEANS=TABLES(A*B)/DESIGN=A B A*B.
COMPUTE K=1.
EXECUTE.
AGGREGATE/OUTFILE=OUT_0/BREAK=K/M_G=MEAN(DV)/N_G=N.
MATCH FILES/FILE=*/TABLE=OUT_0/BY K.
EXECUTE.
SORT CASES BY A(A) B(A).
COMPUTE CELUL=A*100+B.
EXECUTE.
AUTORECODE VARIABLES=CELUL/INTO CELULA.
AGGREGATE/OUTFILE=OUT_1/BREAK=CELULA/M_AB=MEAN(DV)/N_AB=N.
MATCH FILES/FILE=*/TABLE=OUT_1/BY CELULA.
EXECUTE.
AGGREGATE/OUTFILE=OUT_2/BREAK=A/M_A=MEAN(DV)/N_A=N.
MATCH FILES/FILE=*/TABLE=OUT_2/BY A.
EXECUTE.
SORT CASES BY B(A).
AGGREGATE/OUTFILE=OUT_3/BREAK=B/M_B=MEAN(DV)/N_B=N.
MATCH FILES/FILE=*/TABLE=OUT_3/BY B.
EXECUTE.
COMPUTE D2_A=(M_A-M_G)**2.
COMPUTE D2_B=(M_B-M_G)**2.
COMPUTE D2_ERRO=(DV-M_AB)**2.
COMPUTE D2_G=(DV-M_G)**2.
EXECUTE.
AGGREGATE/OUTFILE=*/BREAK=K/N=MEAN(N_AB)/N_T_A=MAX(A)
/N_T_B=MAX(B)/SS_A=SUM(D2_A)/SS_B=SUM(D2_B)
/SS_ERRO=SUM(D2_ERRO)/SS_TOT=SUM(D2_G).
COMPUTE SS_AB=SS_TOT-SS_A-SS_B-SS_ERRO.
COMPUTE GL_A=N_T_A-1.
COMPUTE GL_B=N_T_B-1.
COMPUTE GL_AB=GL_A*GL_B.
COMPUTE GL_ERRO=N*N_T_A*N_T_B-GL_A-GL_B-GL_AB-1.
COMPUTE MS_A=SS_A/GL_A.
COMPUTE MS_B=SS_B/GL_B.
COMPUTE MS_AB=SS_AB/GL_AB.
COMPUTE MS_ERRO=SS_ERRO/GL_ERRO.
COMPUTE COMV_A=(GL_A*(MS_A-MS_ERRO))/(N_T_A*N_T_B*N).
COMPUTE COMV_B=(GL_B*(MS_B-MS_ERRO))/(N_T_A*N_T_B*N).
COMPUTE COMV_AB=(GL_AB*(MS_AB-MS_ERRO))/(N_T_A*N_T_B*N).
COMPUTE COMV_ERR=MS_ERRO.
COMPUTE COMV_TOT=SUM(COMV_A TO COMV_ERR).
COMPUTE ETA_A=SS_A/SS_TOT.
COMPUTE ETA_B=SS_B/SS_TOT.
COMPUTE ETA_AB=SS_AB/SS_TOT.
COMPUTE P_ETA_A=SS_A/(SS_A+SS_ERRO).
COMPUTE P_ETA_B=SS_B/(SS_B+SS_ERRO).
COMPUTE P_ETA_AB=SS_AB/(SS_AB+SS_ERRO).
COMPUTE OME_A=COMV_A/COMV_TOT.
COMPUTE OME_B=COMV_B/COMV_TOT.
COMPUTE OME_AB=COMV_AB/COMV_TOT.
COMPUTE P_OME_A=COMV_A/(COMV_A+COMV_ERR).
COMPUTE P_OME_B=COMV_B/(COMV_B+COMV_ERR).
COMPUTE P_OME_AB=COMV_AB/(COMV_AB+COMV_ERR).
COMPUTE F_COH_A=SQR(P_OME_A/(1-P_OME_A)).
COMPUTE F_COH_B=SQR(P_OME_B/(1-P_OME_B)).
COMPUTE F_COH_AB=SQR(P_OME_AB/(1-P_OME_AB)).
EXECUTE.
FORMATS COMV_A TO F_COH_AB (F8.3).
SUMMARIZE/TABLES=COMV_A COMV_B COMV_AB COMV_ERR/FORMAT=LIST 
NOCASENUM TOTAL/TITLE='Variance Components'/CELLS=NONE.
SUMMARIZE/TABLES=ETA_A ETA_B ETA_AB/FORMAT=LIST NOCASENUM
NOTOTAL/TITLE='Squared Eta'/CELLS=NONE.
SUMMARIZE/TABLES=P_ETA_A P_ETA_B P_ETA_AB/FORMAT=LIST 
NOCASENUM NOTOTAL/TITLE='Parcial Squared Eta'/CELLS=NONE.
SUMMARIZE/TABLES=OME_A OME_B OME_AB/FORMAT=LIST 
NOCASENUM NOTOTAL/TITLE='Squared Omega'/CELLS=NONE.
SUMMARIZE/TABLES=P_OME_A P_OME_B P_OME_AB/FORMAT=LIST 
NOCASENUM NOTOTAL/TITLE='Partial Squared Omega'/CELLS=NONE.
SUMMARIZE/TABLES=F_COH_A F_COH_B F_COH_AB/FORMAT=LIST NOCASENUM 
NOTOTAL/TITLE="Cohen's f"/CELLS=NONE.

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

** METHOD 2: Reproducing the ANOVA Table from summary statistics
** in published articles.

* Enter, row by row, Factor A levels, Factor B levels, N and Mean
* for the experimental conditions (in the example, the same as in 
* Method 1, you have a A3B2 Design).

DATA LIST LIST /a(F8.0) b(F8.0) n(F8.0) m(f8.2).
BEGIN DATA
1  1  4  3,00
1  2  4  11,00
2  1  4  10,00
2  2  4  12,00
3  1  4  14,00
3  2  4  10,00
END DATA.

* Enter Mean Square Error.
COMPUTE mse = 18.333333.

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 a BY b/FORMAT=NOLIST TOTAL
/TITLE='Case Summaries'/CELLS=COUNT MEAN.

* Enter alpha for calculating power(by default, alpha = .05).
UNIANOVA DV BY A B/PRINT=DESCRIPTIVE ETASQ OPOWER/CRITERIA=ALPHA(.05)
/DESIGN=A B A*B.
COMPUTE K=1.
EXECUTE.
AGGREGATE/OUTFILE=OUT_0/BREAK=K/M_G=MEAN(DV)/N_G=N.
MATCH FILES/FILE=*/TABLE=OUT_0/BY K.
EXECUTE.
SORT CASES BY A(A) B(A).
COMPUTE CELUL=A*100+B.
EXECUTE.
AUTORECODE VARIABLES=CELUL/INTO CELULA.
AGGREGATE/OUTFILE=OUT_1/BREAK=CELULA/M_AB=MEAN(DV)/N_AB=N.
MATCH FILES/FILE=*/TABLE=OUT_1/BY CELULA.
EXECUTE.
AGGREGATE/OUTFILE=OUT_2/BREAK=A/M_A=MEAN(DV)/N_A=N.
MATCH FILES/FILE=*/TABLE=OUT_2/BY A.
EXECUTE.
SORT CASES BY B(A).
AGGREGATE/OUTFILE=OUT_3/BREAK=B/M_B=MEAN(DV)/N_B=N.
MATCH FILES/FILE=*/TABLE=OUT_3/BY B.
EXECUTE.
COMPUTE D2_A=(M_A-M_G)**2.
COMPUTE D2_B=(M_B-M_G)**2.
COMPUTE D2_ERRO=(DV-M_AB)**2.
COMPUTE D2_G=(DV-M_G)**2.
EXECUTE.
AGGREGATE/OUTFILE=*/BREAK=K/N=MEAN(N_AB)/N_T_A=MAX(A)
/N_T_B=MAX(B)/SS_A=SUM(D2_A)/SS_B=SUM(D2_B)
/SS_ERRO=SUM(D2_ERRO)/SS_TOT=SUM(D2_G).
COMPUTE SS_AB=SS_TOT-SS_A-SS_B-SS_ERRO.
COMPUTE GL_A=N_T_A-1.
COMPUTE GL_B=N_T_B-1.
COMPUTE GL_AB=GL_A*GL_B.
COMPUTE GL_ERRO=N*N_T_A*N_T_B-GL_A-GL_B-GL_AB-1.
COMPUTE MS_A=SS_A/GL_A.
COMPUTE MS_B=SS_B/GL_B.
COMPUTE MS_AB=SS_AB/GL_AB.
COMPUTE MS_ERRO=SS_ERRO/GL_ERRO.
COMPUTE COMV_A=(GL_A*(MS_A-MS_ERRO))/(N_T_A*N_T_B*N).
COMPUTE COMV_B=(GL_B*(MS_B-MS_ERRO))/(N_T_A*N_T_B*N).
COMPUTE COMV_AB=(GL_AB*(MS_AB-MS_ERRO))/(N_T_A*N_T_B*N).
COMPUTE COMV_ERR=MS_ERRO.
COMPUTE COMV_TOT=SUM(COMV_A TO COMV_ERR).
COMPUTE ETA_A=SS_A/SS_TOT.
COMPUTE ETA_B=SS_B/SS_TOT.
COMPUTE ETA_AB=SS_AB/SS_TOT.
COMPUTE P_ETA_A=SS_A/(SS_A+SS_ERRO).
COMPUTE P_ETA_B=SS_B/(SS_B+SS_ERRO).
COMPUTE P_ETA_AB=SS_AB/(SS_AB+SS_ERRO).
COMPUTE OME_A=COMV_A/COMV_TOT.
COMPUTE OME_B=COMV_B/COMV_TOT.
COMPUTE OME_AB=COMV_AB/COMV_TOT.
COMPUTE P_OME_A=COMV_A/(COMV_A+COMV_ERR).
COMPUTE P_OME_B=COMV_B/(COMV_B+COMV_ERR).
COMPUTE P_OME_AB=COMV_AB/(COMV_AB+COMV_ERR).
COMPUTE F_COH_A=SQR(P_OME_A/(1-P_OME_A)).
COMPUTE F_COH_B=SQR(P_OME_B/(1-P_OME_B)).
COMPUTE F_COH_AB=SQR(P_OME_AB/(1-P_OME_AB)).
EXECUTE.
FORMATS COMV_A TO F_COH_AB (F8.3).
SUMMARIZE/TABLES=COMV_A COMV_B COMV_AB COMV_ERR/FORMAT=LIST 
NOCASENUM TOTAL/TITLE='Variance Components'/CELLS=NONE.
SUMMARIZE/TABLES=ETA_A ETA_B ETA_AB/FORMAT=LIST NOCASENUM
NOTOTAL/TITLE='Squared Eta'/CELLS=NONE.
SUMMARIZE/TABLES=P_ETA_A P_ETA_B P_ETA_AB/FORMAT=LIST 
NOCASENUM NOTOTAL/TITLE='Parcial Squared Eta'/CELLS=NONE.
SUMMARIZE/TABLES=OME_A OME_B OME_AB/FORMAT=LIST 
NOCASENUM NOTOTAL/TITLE='Squared Omega'/CELLS=NONE.
SUMMARIZE/TABLES=P_OME_A P_OME_B P_OME_AB/FORMAT=LIST 
NOCASENUM NOTOTAL/TITLE='Partial Squared Omega'/CELLS=NONE.
SUMMARIZE/TABLES=F_COH_A F_COH_B F_COH_AB/FORMAT=LIST NOCASENUM 
NOTOTAL/TITLE="Cohen's f"/CELLS=NONE.

**********************************************************************
Keppel, G. (1991). Design and analysis: A researcher's handbook
 (3rd ed.). Upper Saddle River, NJ: Prentice Hall.
**********************************************************************