home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frostbyte's 1980s DOS Shareware Collection
/
floppyshareware.zip
/
floppyshareware
/
DOOG
/
PCSSP2.ZIP
/
STATNONP.ZIP
/
MPAIR.FOR
< prev
next >
Wrap
Text File
|
1985-12-31
|
3KB
|
140 lines
C
C ..................................................................
C
C SUBROUTINE MPAIR
C
C PURPOSE
C PERFORM THE WILCOXON MATCHED-PAIRS SIGNED-RANKS TEST, GIVEN
C TWO VECTORS OF N OBSERVATIONS OF THE MATCHED SAMPLES.
C
C USAGE
C CALL MPAIR (N,A,B,K,T,Z,P,D,E,L,IE)
C
C DESCRIPTION OF PARAMETERS
C N - NUMBER OF OBSERVATIONS IN THE VECTORS A AND B
C A - INPUT VECTOR OF LENGTH N CONTAINING DATA FROM THE FIRST
C SAMPLE
C B - INPUT VECTOR OF LENGTH N CONTAINING DATA FROM THE SECOND
C SAMPLE
C K - OUTPUT VARIABLE CONTAINING THE NUMBER OF PAIRS OF THE
C MATCHED SAMPLES WHOSE DIFFERENCES ARE NON ZERO (0)
C T - OUTPUT VARIABLE CONTAINING THE SUM OF THE RANKS OF PLUS
C OR MINUS DIFFERENCES, WHICHEVER IS SMALLER
C Z - VALUE OF THE STANDARDIZED NORMAL SCORE COMPUTED FOR THE
C WILCOXON MATCHED-PAIRS SIGNED-RANKS TEST
C P - COMPUTED PROBABILITY OF OBTAINING A VALUE OF Z AS
C EXTREME AS THE ONE FOUND BY THE TEST
C D - WORKING VECTOR OF LENGTH N
C E - WORKING VECTOR OF LENGTH N
C L - WORKING VECTOR OF LENGTH N
C IE- 1, IF SAMPLES A AND B ARE IDENTICAL.
C 0 OTHERWISE. IF IE=1, THEN T=P=0, AND Z=-10**75
C
C REMARKS
C THE COMPUTED PROBABILTY IS FOR A ONE-TAILED TEST.
C MULTIPLYING P BY 2 WILL GIVE THE VALUE FOR A TWO-TAILED
C TEST.
C
C SUBROUTINES AND FUNCTIONS SUBPROGRAMS REQUIRED
C RANK
C NDTR
C
C METHOD
C REFER TO DIXON AND MASSEY, AN INTRODUCTION TO STATISTICAL
C ANALYSIS (MC GRAW-HILL, 1957)
C
C ..................................................................
C
SUBROUTINE MPAIR (N,A,B,K,T,Z,P,D,E,L,IE)
C
DIMENSION A(1),B(1),D(1),E(1),L(1)
C
IE=0
K=N
C
C FIND DIFFERENCES OF MATCHED-PAIRS
C
BIG=0.0
DO 55 I=1,N
DIF=A(I)-B(I)
IF(DIF) 10, 20, 30
C
C DIFFERENCE HAS A NEGATIVE SIGN (-)
C
10 L(I)=1
GO TO 40
C
C DIFFERENCE IS ZERO (0)
C
20 L(I)=2
K=K-1
GO TO 40
C
C DIFFERENCE HAS A POSITIVE SIGN (+)
C
30 L(I)=3
C
40 DIF= ABS(DIF)
IF(BIG-DIF) 45, 50, 50
45 BIG=DIF
50 D(I)=DIF
C
55 CONTINUE
IF(K) 57,57,59
57 IE=1
T=0.0
Z=-1.0E38
P=0
GO TO 100
C
C STORE A LARGE VALUE IN PLACE OF 0 DIFFERENCE IN ORDER TO
C ASSIGN A LARGE RANK (LARGER THAN K), SO THAT ABSOLUTE VALUES
C OF SIGNED DIFFERENCES WILL BE PROPERLY RANKED
C
59 BIG=BIG*2.0
DO 65 I=1,N
IF(L(I)-2) 65, 60, 65
60 D(I)=BIG
65 CONTINUE
C
CALL RANK (D,E,N)
C
C FIND SUMS OF RANKS OF (+) DIFFERENCES AND (-) DIFFERENCES
C
SUMP=0.0
SUMM=0.0
DO 80 I=1,N
IF(L(I)-2) 70, 80, 75
70 SUMM=SUMM+E(I)
GO TO 80
75 SUMP=SUMP+E(I)
80 CONTINUE
C
C SET T = SMALLER SUM
C
IF(SUMP-SUMM) 85, 85, 90
85 T=SUMP
GO TO 95
90 T=SUMM
C
C COMPUTE MEAN, STANDARD DEVIATION, AND Z
C
95 FK=K
U=FK*(FK+1.0)/4.0
S= SQRT((FK*(FK+1.0)*(2.0*FK+1.0))/24.0)
Z=(T-U)/S
C
C COMPUTE THE PROBABILITY OF A VALUE AS EXTREME AS Z
C
CALL NDTR (Z,P,BIG)
C
100 RETURN
END
O 95
90 T=SUMM
C
C COMPUTE MEAN, STANDARD DEVIATION, AND Z
C
95 FK=K
U=FK*(FK+1.0)/4.0