TPLT Subroutine

public subroutine TPLT(X, N, Nu)

NAME

tplt(3f) - [M_datapac:LINE_PLOT] generates a Student's T probability
plot (with integer degrees of freedom parameter value NU).

SYNOPSIS

   SUBROUTINE TPLT(X,N,Nu)

    REAL(kind=wp),intent(in) :: X(:)
    INTEGER,intent(in) :: N
    INTEGER,intent(in) :: Nu

DESCRIPTION

TPLT(3f) generates a Student's T probability plot (with integer
degrees of freedom parameter value = NU).

The prototype Student's T distribution used herein is defined for all
X, and its probability density function is given in the references
below.

As used herein, a probability plot for a distribution is a plot
of the ordered observations versus the order statistic medians for
that distribution.

The Student's T probability plot is useful in graphically testing
the composite (that is, location and scale parameters need not be
specified) hypothesis that the underlying distribution from which
the data have been randomly drawn is the Student's T distribution
with degrees of freedom parameter value = NU.

If the hypothesis is true, the probability plot should be near-linear.

A measure of such linearity is given by the calculated probability
plot correlation coefficient.

INPUT ARGUMENTS

X      The vector of (unsorted or sorted) observations.
N      The integer number of observations in the vector X.
       The maximum allowable value of N for this subroutine is 7500.
NU     The integer number of degrees of freedom.
       NU should be positive.

OUTPUT

A one-page Student's T probability plot.

EXAMPLES

Sample program:

program demo_tplt
use M_datapac, only : tplt
implicit none
! call tplt(x,y)
end program demo_tplt

Results:

AUTHOR

The original DATAPAC library was written by James Filliben of the
Statistical Engineering Division, National Institute of Standards
and Technology.

MAINTAINER

John Urban, 2022.05.31

LICENSE

CC0-1.0

REFERENCES

  • Filliben, ‘Techniques for Tail Length Analysis’, Proceedings of the Eighteenth Conference on the Design of Experiments in Army Research Development and Testing (Aberdeen, Maryland, October, 1972), pages 425-450.
  • Hahn and Shapiro, Statistical Methods in Engineering, 1967, pages 260-308.
  • National Bureau of Standards Applied Mathematics Series 55, 1964, page 949, FormulA 26.7.5.
  • Johnson and Kotz, Continuous Univariate Distributions–2, 1970, page 102, Formula 11.
  • Federighi, ‘Extended Tables of the Percentage Points of Student’s T Distribution, Journal of the American Statistical Association, 1969, pages 683-688.
  • Hastings and Peacock, Statistical Distributions–A Handbook for Students and Practitioners, 1975, pages 120-123.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: X(:)
integer, intent(in) :: N
integer, intent(in) :: Nu

Common Blocks

CAUPLT (subroutine)
CHSCDF (subroutine)
CODE (subroutine)
DECOMP (subroutine)
DEMOD (subroutine)
DEXPLT (subroutine)
EV1PLT (subroutine)
EV2PLT (subroutine)
EXPPLT (subroutine)
EXTREM (subroutine)
EXTREM (subroutine)
FREQ (subroutine)
GAMPLT (subroutine)
GEOPLT (subroutine)
HFNPLT (subroutine)
INVXWX (subroutine)
LAMPLT (subroutine)
LGNPLT (subroutine)
LOGPLT (subroutine)
MEDIAN (subroutine)
norout (subroutine)
NORPLT (subroutine)
PARPLT (subroutine)
PLOTU (subroutine)
POIPLT (subroutine)
RUNS (subroutine)
SAMPP (subroutine)
SPCORR (subroutine)
TAIL (subroutine)
TRIM (subroutine)
UNIPLT (subroutine)
WEIB (subroutine)
WEIPLT (subroutine)
WIND (subroutine)
"> common /BLOCK2_real64/

Type Attributes Name Initial
real :: WS(15000)

Source Code

SUBROUTINE TPLT(X,N,Nu)
REAL(kind=wp),intent(in) :: X(:)
INTEGER,intent(in) :: N
INTEGER,intent(in) :: Nu

REAL(kind=wp) :: W(7500), Y(7500)
REAL(kind=wp) :: an, cc, hold, pp0025, pp025, pp975, pp9975, q, sum1, sum2, sum3, tau, wbar, WS, ybar, yint, yslope
INTEGER :: i, iupper

COMMON /BLOCK2_real64/ WS(15000)
EQUIVALENCE (Y(1),WS(1))
EQUIVALENCE (W(1),WS(7501))
!
      iupper = 7500
!
!     CHECK THE INPUT ARGUMENTS FOR ERRORS
!
      IF ( N<1 .OR. N>iupper ) THEN
         WRITE (G_IO,99001) iupper
         99001 FORMAT ( &
         & ' ***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO TPLT(3f) IS OUTSIDE THE ALLOWABLE (1,',I0,') INTERVAL *****')
         WRITE (G_IO,99007) N
         RETURN
      ELSEIF ( N==1 ) THEN
         WRITE (G_IO,99002)
         99002 FORMAT (' ***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUMENT TO TPLT(3f) HAS THE VALUE 1 *****')
         RETURN
      ELSE
         IF ( Nu<=0 ) THEN
            WRITE (G_IO,99003)
            99003 FORMAT (' ***** FATAL ERROR--THE THIRD  INPUT ARGUMENT TO TPLT(3f) IS NON-POSITIVE *****')
            WRITE (G_IO,99007) Nu
            RETURN
         ELSE
            hold = X(1)
            DO i = 2 , N
               IF ( X(i)/=hold ) GOTO 50
            ENDDO
            WRITE (G_IO,99004) hold
            99004 FORMAT (' ',&
            &'***** NON-FATAL DIAGNOSTIC--THE FIRST INPUT ARGUMENT (A VECTOR) TO TPLT(3f) HAS ALL ELEMENTS = ',E15.8,' *****')
            RETURN
         ENDIF
!
!-----START POINT-----------------------------------------------------
!
 50      continue
         an = N
!
!     SORT THE DATA
!
         CALL SORT(X,N,Y)
!
!     GENERATE UNIFORM ORDER STATISTIC MEDIANS
!
         CALL UNIMED(N,W)
!
!     COMPUTE STUDENT'S T DISTRIBUTION ORDER STATISTIC MEDIANS
!
         DO i = 1 , N
            CALL TPPF(W(i),Nu,W(i))
         ENDDO
!
!     PLOT THE ORDERED OBSERVATIONS VERSUS ORDER STATISTICS MEDIANS.
!     COMPUTE THE TAIL LENGTH MEASURE OF THE DISTRIBUTION.
!     WRITE OUT THE TAIL LENGTH MEASURE OF THE DISTRIBUTION
!     AND THE SAMPLE SIZE.
!
         CALL PLOT(Y,W,N)
         q = .9975_wp
         CALL TPPF(q,Nu,pp9975)
         q = .0025_wp
         CALL TPPF(q,Nu,pp0025)
         q = .975_wp
         CALL TPPF(q,Nu,pp975)
         q = .025_wp
         CALL TPPF(q,Nu,pp025)
         tau = (pp9975-pp0025)/(pp975-pp025)
         WRITE (G_IO,99005) Nu , tau , N
!
         99005 FORMAT (' STUDENT''S T PROBABILITY PLOT WITH DEGREES OF FREEDOM = '&
          & ,I0,1X,'(TAU = ',E15.8,')',11X,'THE SAMPLE SIZE N = ',I0)
!
!     COMPUTE THE PROBABILITY PLOT CORRELATION COEFFICIENT.
!     COMPUTE LOCATION AND SCALE ESTIMATES
!     FROM THE INTERCEPT AND SLOPE OF THE PROBABILITY PLOT.
!     THEN WRITE THEM OUT.
!
         sum1 = 0.0_wp
         sum2 = 0.0_wp
         DO i = 1 , N
            sum1 = sum1 + Y(i)
            sum2 = sum2 + W(i)
         ENDDO
         ybar = sum1/an
         wbar = sum2/an
         sum1 = 0.0_wp
         sum2 = 0.0_wp
         sum3 = 0.0_wp
         DO i = 1 , N
            sum1 = sum1 + (Y(i)-ybar)*(Y(i)-ybar)
            sum2 = sum2 + (Y(i)-ybar)*(W(i)-wbar)
            sum3 = sum3 + (W(i)-wbar)*(W(i)-wbar)
         ENDDO
         cc = sum2/SQRT(sum3*sum1)
         yslope = sum2/sum3
         yint = ybar - yslope*wbar
         WRITE (G_IO,99006) cc , yint , yslope
         99006    FORMAT (' PROBABILITY PLOT CORRELATION COEFFICIENT = ',F8.5,&
           & 5X,'ESTIMATED INTERCEPT = ',E15.8,3X,                  &
           & 'ESTIMATED SLOPE = ',E15.8)
      ENDIF
      99007 FORMAT (' ***** THE VALUE OF THE ARGUMENT IS ',I0,' *****')
!
END SUBROUTINE TPLT