FRDMN
Performs Friedman’s test for a randomized complete block design.
Required Arguments
NB — Number of blocks. (Input)
NT — Number of treatments. (Input)
Y — Vector of length NB * NT containing the observations. (Input)
The first NT positions of Y contain the observations on treatments 1, 2, , NT in the first block. The second NT positions contain the observations in the second block, etc., and so on.
FUZZ — Constant used to determine ties. (Input)
In the ordered observations, if Y(i) ‑Y(i + 1) is less than or equal to FUZZ, then Y(i) and Y(i + 1) are said to be tied.
ALPHA — Critical level for multiple comparisons. (Input)
ALPHA should be between 0 and 1 exclusive.
STAT — Vector of length 6 containing the Friedman statistics. (Output)
Probabilities reported are computed under the appropriate null hypothesis.
I
STAT(I)
1
Friedman two‑sided test statistic.
2
Approximate F value for STAT(1).
3
Page test statistic for testing the ordered alternative that the median of treatment i is less than or equal to the median of treatment i + 1, with strict inequality holding for some i.
4
Asymptotic p‑value for STAT(1). Chi‑squared approximation.
5
Asymptotic p‑value for STAT(2). F approximation.
6
Asymptotic p‑value for STAT(3). Normal approximation.
SMRNK — Vector of length NT containing the sum of the ranks of each treatment. (Output)
D — Minimum absolute difference in two elements of SMRNK to infer at the alpha level of significance that the medians of the corresponding treatments are different. (Output)
FORTRAN 90 Interface
Generic: CALL FRDMN (NB, NT, Y, FUZZ, ALPHA, STAT, SMRNK, D)
Specific: The specific interface names are S_FRDMN and D_FRDMN.
FORTRAN 77 Interface
Single: CALL FRDMN (NB, NT, Y, FUZZ, ALPHA, STAT, SMRNK, D)
Double: The double precision name is DFRDMN.
Description
Routine FRDMN may be used to test the hypothesis of equality of treatment effects within each block in a randomized block design. No missing values are allowed. Ties are handled by using the average ranks. The test statistic is the nonparametric analogue of an analysis of variance F test statistic.
The test proceeds by first ranking the observations within each block. Let A denote the sum of the squared ranks, i.e., let
where Rank(Yij) is the rank of the i‑th observation within the j‑th block, b = NB is the number of blocks, and k = NT is the number of treatments. Let
where
The Friedman test statistic (STAT(1)) is given by:
that, under the null hypothesis, has an approximate chi‑squared distribution with k  1 degrees of freedom. The asymptotic probability of obtaining a larger chi‑squared random variable is returned in STAT(4).
If the F distribution is used in place of the chi‑squared distribution, then the usual oneway analysis of variance F‑statistic computed on the ranks is used. This statistic, reported in STAT(2), is given by
and asymptotically follows an F distribution with (k  1) and (b  1)(k  1) degrees of freedom under the null hypothesis. STAT(5) is the asymptotic probability of obtaining a larger F random variable. (If A = B, STAT(1) and STAT(2) are set to machine infinity, and the significance levels are reported as k!/(k!)b, unless this computation would cause underflow, in which case the significance levels are reported as zero.) Iman and Davenport (1980) discuss the relative advantages of the chi‑squared and F approximations. In general, the F approximation is considered best.
The Friedman T statistic is related both to the Kendall coefficient of concordance and to the Spearman rank correlation coefficient. See Conover (1980) for a discussion of the relationships.
If, at the α = ALPHA level of significance, the Friedman test results in rejection of the null hypothesis, then an asymptotic test that treatments i and j are different is given by:
reject H0 if Ri  Rj > D, where
where t has (b  1)(k  1) degrees of freedom. Page’s statistic (STAT(3)) is used to test the same null hypothesis as the Friedman test but is sensitive to a monotonic increasing alternative. The Page test statistic is given by
It is largest (and thus most likely to reject) when the Ri are monotonically increasing.
Assumptions
The assumptions in the Friedman test are as follows:
1. The k‑vectors of responses within each of the b blocks are mutually independent (i.e., the results within one block have no effect on the results within another block).
2. Within each block, the observations may be ranked.
The hypothesis tested is that each ranking of the random variables within each block is equally likely. The alternative is that at least one of the treatments tends to have larger values than one or more of the other treatments. The Friedman test is a test for the equality of treatment means or medians.
Comments
1. Workspace may be explicitly provided, if desired, by use of F2DMN/DF2DMN. The reference is:
CALL F2DMN (NB, NT, Y, FUZZ, ALPHA, STAT, SMRNK, D, IWK, WK)
The additional arguments are as follows:
IWK — Integer work vector of length NT.
WK — Work vector of length 2 * NT.
2. Informational errors
Type
Code
Description
4
5
At least one missing value was detected in Y. No missing values are permitted in this routine since it assumes a complete block design.
3
6
At least one tie was detected within a block.
3
7
The ranks of the treatments were exactly the same in all the blocks.
Example
The following example is taken from Bradley (1968), page 127, and tests the hypothesis that 4 drugs have the same effects upon a person’s visual acuity. Five subjects were used.
 
USE FRDMN_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER NB, NT
REAL ALPHA, FUZZ
PARAMETER (ALPHA=0.05, FUZZ=0.001, NB=5, NT=4)
!
INTEGER NOUT
REAL D, SMRNK(NT), STAT(6), Y(NB*NT)
!
DATA Y/.39, .55, .33, .41, .21, .28, .19, .16, .73, .69, .64, &
.62, .41, .57, .28, .35, .65, .57, .53, .60/
! Perform Friedman's test
CALL FRDMN (NB, NT, Y, FUZZ, ALPHA, STAT, SMRNK, D)
! Print results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) STAT, SMRNK, D
!
99999 FORMAT (' Friedman T.........', F8.2, /, ' Friedman F.........', &
F8.2, /, ' Page test..........', F8.2, /, ' Prob ', &
'Friedman T....', F11.5, /, ' Prob Friedman F....', &
F11.5, /, ' Prob Page test.....', F11.5, /, ' Sum of ', &
'Ranks.......', 4F8.2, /, ' D..................', F11.5)
!
END
Output
 
Friedman T......... 8.28
Friedman F......... 4.93
Page test.......... 111.00
Prob Friedman T.... 0.04057
Prob Friedman F.... 0.01859
Prob Page test..... 0.98495
Sum of Ranks....... 16.00 17.00 7.00 10.00
D.................. 6.65638
The Friedman null hypothesis is rejected at the α = .05 while the Page null hypothesis is not. (A Page test with a monotonic decreasing alternative would be rejected, however.) Using SMRNK and D, one can conclude that treatment 3 is different from treatments 1 and 2, and that treatment 4 is different from treatment 2, all at the α = .05 level of significance.