SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Contacts SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Auxiliary Chapter

QUANTILE

Name:
    QUANTILE (LET)
Type:
    Let Subcommand
Purpose:
    Compute a user specified quantile for a variable.
Description:
    The qth quantile of a data set is defined as that value where a q fraction of the data is below that value and (1-q) fraction of the data is above that value. For example, the 0.5 quantile is the median.

    Dataplot supports two methods for computing the quantile.

    The first method is based on the order statistic. The formula is:

      Xhat(q) = (1 - r)*X(NI1) + r*X(NI2)

    where

      X are the observations sorted in ascending order
      NI1 = INT(q*(n+1))
      NI2 = NI1 + 1
      r = q*(n+1) - INT(q*(n+1))

    An alternative method is called the Herrell-Davis estimate. This method attempts to provide a lower standard error for Xq by utilizing all the order statistics rather than a single (or a weighted average of two) order statistic. Note that there are caes where the Herrell-Davis has a substantially smaller standard error than the order statistic method. However, there are also cases where the reverse is true.

    To compute the Herrell-Davis estimate, do the following:

    1. Sort the X in ascending order.

    2. A = (n+1)*q - 1

    3. B = (n+1)*(1 - q) - 1

    4. Wi = BETCDF(i/n,A,B) - BETCDF((i-1)/n,A,B) where BETCDF is the beta cumulative distribution function with shape parameters A and B.

    5. Xhat(q) = SUM[i=1 to n][W(i)*X(i)]

    Note: The computations for A and B were modified 2/2003 to:

      A = (n+1)*q
      B = (n+1)*(1 - q)

    The original form was from the text in the Wilcox book. However, checking his S+ macros and verifying against the original Herrell and Davis article indicated that the new formulas are the correct ones.

Syntax:
    LET <par> = <quant> QUANTILE <y>        <SUBSET/EXCEPT/FOR qualification>
    where <y> is the response variable;
                  <quant> is a number or parameter in the range (0,1) that specifies the desired quantile;
                  <par> is a parameter where the computed quantile is stored;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    LET A = 0.20 QUANTILE Y

    LET XQ = 0.50
    LET A = XQ QUANTILE Y SUBSET TAG > 2

Note:
    The PERCENTILE command is equivalent to the QUANTILE command using the order statistic method. The only difference is that the requested percentile is given as a percentage between 0 and 100% rather than as a fraction.
Note:
    The following command is used to determine which method is used to compute the quantile:

      SET QUANTILE METHOD <ORDER/HERRELL-DAVIS>
Note:
    Support for the quantile has been added to the following plots:

      QUANTILE PLOT
      CROSS TABULATE QUANTILE PLOT
      BOOTSTRAP QUANTILE PLOT
      JACKNIFE QUANTILE PLOT
      DEX QUANTILE PLOT
      QUANTILE INFLUENCE CURVE
      INTERACTION QUANTILE PLOT

    The specific quantile to compute is specified by entering the following command (before the plot command):

      LET XQ = <value>

    where is a number in the interval (0,1) that specifies the desired quantile.

Default:
    The default is to use the order statistic method to compute the quantile.
Synonyms:
    None
Related Commands:
    PERCENTILE = Compute a percentile of a variable.
    MEDIAN = Compute the median of a variable.
    LOWER QUARTILE = Compute the lower quartile of a variable.
    UPPER QUARTILE = Compute the upper quartile of a variable.
    FIRST DECILE = Compute the first decile (the 10th quantile) of a variable.
    STATISTIC PLOT = Generate a statistic versus subset plot for a given statistics.
    CROSS TABULATE PLOT = Generate a statistic versus subset plot (two group variables) for a given statistics.
    BOOTSTRAP PLOT = Generate a bootstrap plot for a given statistic.
    INFLUENCE CURVE = Generate an influence curve for a given statistic.
    DEX PLOT = Generate a dex plot for a given statistic.
    INTERACTION STATISTIC PLOT = Generate a dex plot for a given statistic.
Reference:
    "Introduction to Robust Estimation and Hypothesis Testing", Rand Wilcox, Academic Press, 1997.

    "A New Distribution-Free Quantile Estimator", Frank Herrell and C. E. Davis, Biometrika (1982), 69(3), 635-640.

Applications:
    Data Analysis
Implementation Date:
    2002/7
    2003/2: Correction to Herrell-Davis estimate.
Program:
    LET Y1 = LOGISTIC RANDOM NUMBERS FOR I = 1 1 100 
    LET XQ = 0.05 
    LET P05 = XQ QUANTILE Y1 
    LET XQ = 0.95 
    LET P95 = XQ QUANTILE Y1 
    SET QUANTILE METHOD HERRELL DAVIS
    LET XQ = 0.05 
    LET P05 = XQ QUANTILE Y1 
    LET XQ = 0.95 
    LET P95 = XQ QUANTILE Y1 
        

Date created: 7/22/2002
Last updated: 4/4/2003
Please email comments on this WWW page to alan.heckert@nist.gov.