C
C     ..................................................................
C
C	 SUBROUTINE BISER
C
C	 PURPOSE
C	    TO COMPUTE THE BISERIAL CORRELATION COEFFICIENT BETWEEN TWO
C	    CONTINUOUS VARIABLES WHEN ONE OF THEM HAS BEEN ARTIFICIALLY
C	    DICHOTOMIZED.
C
C	 USAGE
C	    CALL BISER (N,A,B,HI,ANS,IER)
C
C	 DESCRIPTION OF PARAMETERS
C	    N	- NUMBER OF OBSERVATIONS
C	    A	- INPUT VECTOR OF LENGTH N CONTAINING THE CONTINUOUS
C		  VARIABLE
C	    B	- INPUT VECTOR OF LENGTH N CONTAINING THE DICHOTOMIZED
C		  VARIABLE
C	    HI	- INPUT - NUMERICAL CODE TO INDICATE THE HIGHER CATEGORY
C		  OF THE DICHOTOMIZED VARIABLE.  ANY VALUE IN VECTOR B
C		  EQUAL TO OR GREATER THAN HI WILL BE CLASSIFIED INTO
C		  THE HIGHER CATEGORY.
C	    ANS - OUTPUT VECTOR OF LENGTH 8 CONTAINING THE FOLLOWING
C		  ANS(1) - MEAN OF VARIABLE A
C		  ANS(2) - STANDARD DEVIATION OF VARIABLE A
C		  ANS(3) - PROPORTION OF THE CASES IN THE HIGHER
C			   CATEGORY OF VARIABLE B
C		  ANS(4) - PROPORTION OF THE CASES IN THE LOWER
C			   CATEGORY OF VARIABLE B
C		  ANS(5) - MEAN OF VARIABLE A FOR THOSE CASES FALLING
C			   INTO THE HIGHER CATEGORY OF VARIABLE B
C		  ANS(6) - MEAN OF VARIABLE A FOR THOSE CASES FALLING
C			   INTO THE LOWER CATEGORY OF VARIABLE B
C		  ANS(7) - BISERIAL CORRELATION COEFFICIENT
C		  ANS(8) - STANDARD ERROR OF BISERIAL CORRELATION
C			   COEFFICIENT
C	    IER -  1, IF NO CASES ARE IN THE LOWER CATEGORY OF VARIABLE
C		  B.
C		  -1, IF ALL CASES ARE IN THE LOWER CATEGORY OF
C		  VARIABLE B.
C		  0, OTHERWISE.
C		  IF IER IS NON-ZERO, ANS(I)=10**75,I=5,...,8.
C
C	 REMARKS
C	    THE VALUES OF THE DICHOTOMIZED VARIABLE, B, MUST BE IN
C	    NUMERIC FORM.  THEY CANNOR BE SPECIFIED BY MEANS OF
C	    ALPHABETIC OR SPECIAL CHARACTERS.
C
C	 SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C	    NDTRI
C
C	 METHOD
C	    REFER TO P. HORST, 'PSYCHOLOGICAL MEASUREMENT AND
C	    PREDICTION', P.95-96 (WADSWORTH, 1966).
C
C     ..................................................................
C
      SUBROUTINE BISER (N,A,B,HI,ANS,IER)
C
      DIMENSION A(1),B(1),ANS(1)
C
C	 COMPUTE MEAN AND STANDARD DEVIATION OF VARIABLE A
C
      IER=0
      SUM=0.0
      SUM2=0.0
      DO 10 I=1,N
      SUM=SUM+A(I)
   10 SUM2=SUM2+A(I)*A(I)
      FN=N
      ANS(1)=SUM/FN
      ANS(2)=(SUM2-ANS(1)*SUM)/(FN-1.0)
      ANS(2)= SQRT(ANS(2))
C
C	 FIND PROPORTIONS OF CASES IN THE HIGHER AND LOWER CATEGORIES
C
      P=0.0
      SUM=0.0
      SUM2=0.0
      DO 30 I=1,N
      IF(B(I)-HI) 20, 25, 25
   20 SUM2=SUM2+A(I)
      GO TO 30
   25 P=P+1.0
      SUM=SUM+A(I)
   30 CONTINUE
      ANS(4)=1.0
      ANS(3)=0.0
      Q=FN-P
      IF (P) 35,35,40
   35 IER=-1
      GO TO 50
   40 ANS(5)=SUM/P
      IF (Q) 45,45,60
   45 IER=1
      ANS(4)=0.0
      ANS(3)=1.0
   50 DO 55 I=5,8
   55 ANS(I)=1.E38
      GO TO 65
   60 ANS(6)=SUM2/Q
      P=P/FN
      Q=1.0-P
C
C	 FIND ORDINATE OF THE NORMAL DISTRIBUTION CURVE AT THE POINT OF
C	 DIVISION BETWEEN SEGMENTS CONTAINING P AND Q PROPORTIONS
C
      CALL NDTRI (Q,X,Y,ER)
C
C	 COMPUTE THE BISERIAL COEFFICIENT OF CORRELATION
C
      R=((ANS(5)-ANS(1))/ANS(2))*(P/Y)
C
C	 COMPUTE THE STANDARD ERROR OF R
C
      ANS(8)=( SQRT(P*Q)/Y-R*R)/SQRT(FN)
C
C	 STORE RESULTS
C
      ANS(3)=P
      ANS(4)=Q
      ANS(7)=R
C
   65 RETURN
      END
 ANS(6)=SUM2/Q
      P=P/FN
      Q=1.0-P
C
