Friedman Two Way Analysis of Variance by Ranks

© 1998 by Dr. Thomas W. MacFarland -- All Rights Reserved


************
friedman.doc
************
Background:  Friedman Two Way Analysis of Variance is a useful
             test when:

             1.  it is desirable to know if differences exist
                 between three or more samples

             2.  data are ordinal (i.e., ranked)

             It is generally desirable to structure a design so
             that a parametric analysis is used.  But, as the later
             sample demonstrates, there are many times when it is
             only possible to use ordinal data.  When that is the
             case, the Friedman test may be an appropriate 
             alternate statistical aid when looking at multiple
             analyses and possible interaction.


Scenario:    This file examines possible differences in graded 
             performance to three separate activities (e.g., 
             final examination score, composite score for all 
             homework problems, final project score) in a high 
             school Logo programming language class.  

             To add greater precision to this analysis, this 
             analysis will further determine:

             -- differences by gender

                1 = Female 
                2 = Male  

             -- adherence to the prerequisite BASIC programming 
                course

                1 = Yes, Prerequisite Passed 
                2 = No, Prerequisite Waived

             Because the teacher conducting this analysis has a 
             concern that homework scores and final project scores 
             are ordinal data (data are ordered, but not with the 
             precision of interval data), it is best to use the non-
             parametric Friedman test instead of the Twoway 
             Analysis of Variance (ANOVA) test, which is based on 
             the use of interval data.

             A visual presentation of the data is provided in 
             Table 1.   


             Table 1

             Graded Activities (Final Examination, Homework, 
             Project) in a High School Logo Programming Course
             by Gender and by Adherence to a Prerequisite 
             BASIC Programming Course  
             =========================================================   

                           Gender    Pre_Req
                         ----------  ---------
               Student   1 = Female  1 = Yes
               Number    2 = Male    2 = No     Final Home_Wk  Project
             ---------------------------------------------------------

                   01        1         1         086   091      067
                   02        2         1         088   089      074
                   03        1         1         067   073      057
                   04        1         2         083   091      093
                   05        2         1         082   085      080
                   06        2         1         083   078      092
                   07        2         2         055   071      065
                   08        1         2         087   093      072
                   09        1         2         088   083      081
                   10        1         1         093   096      084
                   11        1         2         086   075      065
                   12        2         2         087   094      100
                   13        1         1         088   097      093
                   14        1         1         082   078      075
                   15        1         1         088   083      094
                   16        1         1         074   079      098
                   17        2         2         069   082      076
                   18        1         1         094   087      095
                   19        2         2         075   072      084
                   20        1         2         074   076      068
                   21        1         2         085   078      093
                   22        1         2         087   087      082
                   23        1         1         082   092      076
                   24        1         1         094   096      090
                   25        2         1         068   073      082
             ---------------------------------------------------------


Ho:          Null Hypothesis:  There is no difference in graded 
             performance to three separate activities (e.g., 
             final examination score, composite score for all 
             homework problems, final project score) between
             students in a high school Logo programming language 
             class by gender (male/female) and adherence to a 
             prerequisite BASIC programming course (yes/no) 
             (p = .05).


Files:       1.  friedman.doc

             2.  friedman.dat

             3.  friedman.r01

             4.  friedman.o01

             5.  friedman.con 

             6.  friedman.lis


Command:     At the Unix prompt (%), key:

             %spss -m < friedman.r01 > friedman.o01 


************
friedman.dat
************ 
                   01        1         1         086   091      067
                   02        2         1         088   089      074
                   03        1         1         067   073      057
                   04        1         2         083   091      093
                   05        2         1         082   085      080
                   06        2         1         083   078      092
                   07        2         2         055   071      065
                   08        1         2         087   093      072
                   09        1         2         088   083      081
                   10        1         1         093   096      084
                   11        1         2         086   075      065
                   12        2         2         087   094      100
                   13        1         1         088   097      093
                   14        1         1         082   078      075
                   15        1         1         088   083      094
                   16        1         1         074   079      098
                   17        2         2         069   082      076
                   18        1         1         094   087      095
                   19        2         2         075   072      084
                   20        1         2         074   076      068
                   21        1         2         085   078      093
                   22        1         2         087   087      082
                   23        1         1         082   092      076
                   24        1         1         094   096      090
                   25        2         1         068   073      082


************
friedman.r01
************
SET WIDTH      = 80
SET LENGTH     = NONE
SET CASE       = UPLOW
SET HEADER     = NO
TITLE          = Friedman Twoway ANOVA by Ranks
COMMENT        = This file examines possible differences 
                 in graded performance to three separate 
                 activities (e.g., final examination score, 
                 composite score for all homework problems, 
                 final project score) in a high school Logo 
                 programming language class.  To add greater
                 precision to this analysis, this analysis 
                 will further determine differences by gender
                 (1 = Female and 2 = Male) and adherence to
                 the prerequisite BASIC programming course
                 (1 = Yes, Prerequisite Passed and 2 = No,
                 Prerequisite Waived).

                 Because the teacher conducting this analysis
                 has a concern that homework scores and final 
                 project scores are ordinal data (data are ordered, 
                 but not with the precision of interval data), it
                 is best to use the non-parametric Friedman test 
                 instead of the Twoway Analysis of Variance (ANOVA)
                 based on the use of interval data.
DATA LIST FILE = 'friedman.dat' FIXED
     / Stu_Code    20-21
       Gender         30 
       Pre_Req        40 
       Final       50-52
       Home_Wk     56-58
       Project     65-67

Variable Lables
       Stu_Code   "Student Code"
     / Gender     "Gender"    
     / Pre_Req    "Prerequisite Status" 

Value Labels
       Gender   1 'Female' 
                2 'Male'

     / Pre_Req  1 "Yes, Passed" 
                2 "No, Waived"

NPAR TESTS FRIEDMAN = Final Home_Wk Project 


************
friedman.o01
************
   2  SET WIDTH      = 80
   3  SET LENGTH     = NONE
   4  SET CASE       = UPLOW
   5  SET HEADER     = NO
   6  TITLE          = Friedman Twoway ANOVA by Ranks
   7  COMMENT        = This file examines possible differences
   8                   in graded performance to three separate
   9                   activities (e.g., final examination score,
  10                   composite score for all homework problems,
  11                   final project score) in a high school Logo
  12                   programming language class.  To add greater
  13                   precision to this analysis, this analysis
  14                   will further determine differences by gender
  15                   (1 = Female and 2 = Male  and adherence to
  16                   the prerequisite BASIC programming course
  17                   (1 = Yes, Prerequisite Passed and 2 = No,
  18                   Prerequisite Waived).
  19
  20                   Because the teacher conducting this analysis
  21                   has a concern that homework scores and final
  22                   project scores are ordinal data (data are ordered,
  23                   but not with the precision of interval data), it
  24                   is best to use the non-parametric Friedman test
  25                   instead of the Twoway Analysis of Variance (ANOVA)
  26                   based on the use of interval data.
  27  DATA LIST FILE = 'friedman.dat' FIXED
  28       / Stu_Code    20-21
  29         Gender         30
  30         Pre_Req        40
  31         Final       50-52
  32         Home_Wk     56-58
  33         Project     65-67
  34

This command will read 1 records from friedman.dat

Variable   Rec   Start     End         Format

STU_CODE     1      20      21         F2.0
GENDER       1      30      30         F1.0
PRE_REQ      1      40      40         F1.0
FINAL        1      50      52         F3.0
HOME_WK      1      56      58         F3.0
PROJECT      1      65      67         F3.0

  35  Variable Lables
  36         Stu_Code   "Student Code"
  37       / Gender     "Gender"
  38       / Pre_Req    "Prerequisite Status"
  39
  40  Value Labels
  41         Gender   1 'Female'
  42                  2 'Male'
  43
  44       / Pre_Req  1 "Yes, Passed"
  45                  2 "No, Waived"
  46
  47  NPAR TESTS FRIEDMAN = Final Home_Wk Project
***** Workspace allows for 16384 cases for NPAR tests *****



- - - - - Friedman Two-Way Anova


     Mean Rank   Variable

          1.86   FINAL
          2.30   HOME_WK
          1.84   PROJECT

          Cases        Chi-Square          D.F.   Significance
            25            3.3800             2          .1845


************
friedman.con
************

Outcome:     Computed Fr = 3.3800   (Fr approximates Chi-square)

             df = k-1 = 3-1 = 2 

             Criterion Fr (alpha = .05, df = 2) = 5.9915

             Computed Fr (3.3800) < Criterion Fr (5.9915)

             Therefore, the null hypothesis is accepted and
             it can be claimed that there is no difference in
             the graded performance to three separate activities 
             (e.g., final examination score, composite score for 
             all homework problems, final project score) in a 
             high school Logo programming language class by
             gender and by adherence to a prerequisite BASIC
             programming course (p = .05).

             The p value is another way to view differences in
             the three graded activities:

             -- The calculated p value is .1845.

             -- The delcared p value is .05.

             The calculated p value exceeds the declared p value 
             and there is, accordingly, no difference in scores 
             of the three graded activities at this level of 
             significance by gender and by adherence to a 
             prerequisite BASIC programming course (p = .05).  
             Differences in mean rankings of scores for all three 
             graded activities are due only to chance.


Note:        Although the test statistic for Friedman Two Way
             Anova is "Fr," you will notice that chi-square
             values are used for data analysis.  Fr approximates
             the chi-square distribution. 


************
friedman.lis
************
% minitab

 MTB > outfile 'friedman.lis'
 Collecting Minitab session in file: friedman.lis
 MTB > # MINITAB addendum to friedman.dat
 MTB > read 'friedman.dat' c1-c6
 Entering data from file: friedman.dat
      25 rows read.
 MTB > print c1-c6
 
 
  ROW    C1   C2   C3    C4    C5     C6
 
    1     1    1    1    86    91     67
    2     2    2    1    88    89     74
    3     3    1    1    67    73     57
    4     4    1    2    83    91     93
    5     5    2    1    82    85     80
    6     6    2    1    83    78     92
    7     7    2    2    55    71     65
    8     8    1    2    87    93     72
    9     9    1    2    88    83     81
   10    10    1    1    93    96     84
   11    11    1    2    86    75     65
   12    12    2    2    87    94    100
   13    13    1    1    88    97     93
   14    14    1    1    82    78     75
   15    15    1    1    88    83     94
   16    16    1    1    74    79     98
   17    17    2    2    69    82     76
   18    18    1    1    94    87     95
 Continue? y
   19    19    2    2    75    72     84
   20    20    1    2    74    76     68
   21    21    1    2    85    78     93
   22    22    1    2    87    87     82
   23    23    1    1    82    92     76
   24    24    1    1    94    96     90
   25    25    2    1    68    73     82
 
 MTB > # The series of MINITAB commands to conduct the
 MTB > # Friedman Twoway ANOVA statistic is far too
 MTB > # complex for our needs.
 MTB > #
 MTB > # Fortunately, the Chi-square statistic approximates
 MTB > # the Friedman statistic.  
 MTB > # I will use the Chi-square test to obtain a
 MTB > # reasonable estimate of Friedman.
 MTB > chisquare c4-c6
 
 Continue? y
 Expected counts are printed below observed counts
 
             C4       C5       C6    Total
     1       86       91       67      244
          80.74    82.87    80.39
 
     2       88       89       74      251
          83.06    85.25    82.69
 
     3       67       73       57      197
          65.19    66.91    64.90
 
     4       83       91       93      267
          88.35    90.68    87.96
 
     5       82       85       80      247
          81.73    83.89    81.37
 
     6       83       78       92      253
          83.72    85.93    83.35
 
     7       55       71       65      191
          63.20    64.87    62.92
 Continue? y
     8       87       93       72      252
          83.39    85.59    83.02
 
     9       88       83       81      252
          83.39    85.59    83.02
 
    10       93       96       84      273
          90.34    92.72    89.94
 
    11       86       75       65      226
          74.78    76.76    74.46
 
    12       87       94      100      281
          92.98    95.44    92.58
 
    13       88       97       93      278
          91.99    94.42    91.59
 
    14       82       78       75      235
          77.76    79.82    77.42
 
    15       88       83       94      265
          87.69    90.01    87.30
 Continue? y
    16       74       79       98      251
          83.06    85.25    82.69
 
    17       69       82       76      227
          75.12    77.10    74.79
 
    18       94       87       95      276
          91.33    93.74    90.93
 
    19       75       72       84      231
          76.44    78.46    76.10
 
    20       74       76       68      218
          72.14    74.04    71.82
 
    21       85       78       93      256
          84.71    86.95    84.34
 
    22       87       87       82      256
          84.71    86.95    84.34
 
    23       82       92       76      250
          82.73    84.91    82.36
 Continue? y
    24       94       96       90      280
          92.65    95.10    92.25
 
    25       68       73       82      223
          73.79    75.74    73.47
 
 Total     2045     2099     2036     6180
 
 Continue? y
 ChiSq =  0.343 +  0.797 +  2.229 +
          0.294 +  0.165 +  0.914 +
          0.050 +  0.554 +  0.962 +
          0.324 +  0.001 +  0.288 +
          0.001 +  0.015 +  0.023 +
          0.006 +  0.732 +  0.898 +
          1.065 +  0.579 +  0.068 +
          0.156 +  0.641 +  1.463 +
          0.255 +  0.078 +  0.049 +
          0.078 +  0.116 +  0.392 +
          1.682 +  0.040 +  1.201 +
          0.385 +  0.022 +  0.595 +
          0.173 +  0.070 +  0.022 +
          0.231 +  0.041 +  0.076 +
          0.001 +  0.545 +  0.514 +
          0.988 +  0.458 +  2.834 +
          0.498 +  0.312 +  0.020 +
          0.078 +  0.485 +  0.182 +
          0.027 +  0.532 +  0.819 +
          0.048 +  0.052 +  0.203 +
          0.001 +  0.921 +  0.889 +
          0.062 +  0.000 +  0.065 +
          0.006 +  0.592 +  0.491 +
 Continue? y
          0.020 +  0.009 +  0.055 +
          0.455 +  0.099 +  0.991 = 31.327
 df = 48
 
 MTB > # Computed Chi-square = 31.327 (df = 48)
 MTB > #
 MTB > # Criterion Chi-square = 67.505 (p <= .05 and df = 50)
 MTB > # 
 MTB > # Note how I used the table value for Chi-square with 
 MTB > # df = 50, not df = 48.  Most tables present criterion
 MTB > # values for Chi-square from 1 to 30, and then increments
 MTB > # from 30 to 40, 40 to 50, etc.
 MTB > #
 MTB > # Because the computed Chi-square statistic (31.327) is
 MTB > # less than the criterion Chi-square statistic (67.505),
 MTB > # accept the Null Hypothesis.  There is no difference in
 MTB > # grades on the three activities:  final examination,
 MTB > # homework, project.
 MTB > stop


--------------------------
Disclaimer:  All care was used to prepare the information in this 
tutorial.  Even so, the author does not and cannot guarantee the 
accuracy of this information.  The author disclaims any and all 
injury that may come about from the use of this tutorial.  As 
always, students and all others should check with their advisor(s) 
and/or other appropriate professionals for any and all assistance 
on research design, analysis, selected levels of significance, and 
interpretation of output file(s).

The author is entitled to exclusive distribution of this tutorial. 
Readers have permission to print this tutorial for individual use, 
provided that the copyright statement appears and that there is no 
redistribution of this tutorial without permission.

Prepared 980316
Revised  980914
end-of-file 'friedman.ssi'

Please send comments or suggestions to Dr. Thomas W. MacFarland

There have been [an error occurred while processing this directive] visitors to this page since February 1, 1999.