EQTIL
Computes empirical quantiles.
Required Arguments
X — Vector of length NOBS containing the data. (Input)
NQPROP — Number of quantiles. (Input)
NQPROP must be greater than or equal to one.
QPROP — Vector of length NQPROP containing the quantile proportions. (Input)
The elements of QPROP must lie in the interval (0, 1).
Q — Vector of length NQPROP containing the empirical quantiles. (Output)
Q(i) corresponds to the empirical quantile at proportion QPROP(i). The quantiles are determined by linear interpolation between adjacent ordered sample values.
XLO — Vector of length NQPROP containing the largest element of X less than or equal to the desired quantile. (Output)
XHI — Vector of length NQPROP containing the smallest element of X greater than or equal to the desired quantile. (Output)
NMISS — Number of missing values. (Output)
Optional Arguments
NOBS — Number of observations. (Input)
NOBS must be greater than or equal to one.
Default: NOBS = size (X,1).
FORTRAN 90 Interface
Generic: CALL EQTIL (X, NQPROP, QPROP, Q, XLO, XHI, NMISS [])
Specific: The specific interface names are S_EQTIL and D_EQTIL.
FORTRAN 77 Interface
Single: CALL EQTIL (NOBS, X, NQPROP, QPROP, Q, XLO, XHI, NMISS)
Double: The double precision name is DEQTIL.
Description
The routine EQTIL determines the empirical quantiles, as indicated in the vector QPROP, from the data in X. The routine EQTIL first checks to see if X is sorted; if X is not sorted, the routine does either a complete or partial sort, depending on how many order statistics are required to compute the quantiles requested.
The routine EQTIL returns the empirical quantiles and, for each quantile, the two order statistics from the sample that are at least as large and at least as small as the quantile. For a sample of size n, the quantile corresponding to the proportion p is defined as
Q(p) = (1   f )xj + f xj + 1
where j = p(n + 1), f = p(n + 1)  j, and xj is the j-th order statistic, if 1 j < n; otherwise, the empirical quantile is the smallest or largest order statistic.
Comments
1. Workspace may be explicitly provided, if desired, by use of E2TIL/DE2TIL. The reference is:
CALL E2TIL (NOBS, X, NQPROP, QPROP, Q, XLO, XHI, NMISS, WK)
The additional argument is:
WK — Workspace of length NOBS containing the sorted data. (Output)
If X is sorted in ascending order with all missing values at the end of X, then X and WK may share the same storage location.
2. Informational error
Type
Code
Description
3
1
All of the observations are missing values. The elements of Q, XLO, and XHI have been set to NaN (not a number).
3. Missing values (NaN) are excluded from the analysis. Empirical quantiles are based on the NOBS  NMISS nonmissing elements of X.
Example
In this example, five empirical quantiles from a sample of size 30 are obtained. Notice that the 0.5 quantile corresponds to the sample median. The data are from Hinkley (1977) and Velleman and Hoaglin (1981). They are the measurements (in inches) of precipitation in Minneapolis/St. Paul during the month of March for 30 consecutive years.
 
USE EQTIL_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER NOBS, NQPROP
PARAMETER (NOBS=30, NQPROP=5)
!
INTEGER I, NMISS, NOUT
REAL QPROP(NQPROP), X(NOBS), XEMP(NQPROP), XHI(NQPROP),&
XLO(NQPROP)
!
DATA X/0.77, 1.74, 0.81, 1.20, 1.95, 1.20, 0.47, 1.43, 3.37, &
2.20, 3.00, 3.09, 1.51, 2.10, 0.52, 1.62, 1.31, 0.32, 0.59, &
0.81, 2.81, 1.87, 1.18, 1.35, 4.75, 2.48, 0.96, 1.89, 0.90, &
2.05/
DATA QPROP/0.01, 0.50, 0.90, 0.95, 0.99/
!
CALL UMACH (2, NOUT)
CALL EQTIL (X, NQPROP, QPROP, XEMP, XLO, XHI, NMISS)
WRITE (NOUT,99997)
99997 FORMAT (' Smaller Empirical Larger', /, &
' Quantile Datum Quantile Datum')
DO 10 I=1, NQPROP
WRITE (NOUT,99998) QPROP(I), XLO(I), XEMP(I), XHI(I)
10 CONTINUE
99998 FORMAT (4X, F4.2, 8X, F4.2, 8X, F4.2, 8X, F4.2)
WRITE (NOUT,99999) NMISS
99999 FORMAT (/, ' There are ', I2, ' missing values.')
END
Output
 
Smaller Empirical Larger
Quantile Datum Quantile Datum
0.01 0.32 0.32 0.32
0.50 1.43 1.47 1.51
0.90 3.00 3.08 3.09
0.95 3.37 3.99 4.75
0.99 4.75 4.75 4.75
 
There are 0 missing values.
Published date: 03/19/2020
Last modified date: 03/19/2020