SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

MEAN RANK

Name:
    MEAN RANK (LET)
Type:
    Let Subcommand
Purpose:
    Compute an average (mean) rank for a response variable over one to six group-id variables.
Description:
    Given a response variable, one to six group-id variables, and a sequence variable this command does the following

    1. Cross-tabulate the response variable based on the group-id variables. Each cell of the cross-tabulation will contain all the response values for that cell.

      For each row of the response variable within the cell there will be a corresponding sequence number.

      The sequence number is used so that missing values can be accommodated and so that the response values do not have to be in a specific order. If the response values do not have missing data and are already sorted in the correct order, you can use the SEQUENCE command to create the sequence variable. For example, if there are eight cells with 10 responses each, enter

        LET XSEQ = SEQUENCE 1 10 1 8

      In other cases, the sequence id might be another group-id variable such as a batch id or a method id.

    2. Within each cross-tabulation cell, rank the response values.

    3. The final step is to then compute the mean rank for each distinct value of the sequence variable over all the cross-tabulation cells.

    A typical use of this command is to see how a method (or batch or some other variable of interest) performs across various conditions of several other factor variables.

Syntax:
    LET <yrank> = MEAN RANK <y> <xseq> <x1> ... <xk>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y> is a response variable;
                <xseq> is a variable that defines the sequence number for the response variable;
                <x1> ... <x6> is a list of one to six group-id variables;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    LET AVERANK = MEAN RANK Y XSEQ X1 X2 X3
    LET AVERANK = MEAN RANK Y XSEQ X1 X2 X3 SUBSET XSEQ = 2 TO 10
Note:
    The response values are ranked in ascending order.
Note:
    The groups in the data do not need to be pre-sorted or contiguous. The ranked response variable will be in the same order as the original response variable (i.e., the groups are not sorted on output).
Note:
    By default, the output variable will have the same number of elements as the input variables. However, if you enter the command

      SET LET CROSS TABULATE COLLAPSE

    only a single value will be saved in the output variable for each distinct combination of the group-id variables.

    In order to preserve the appropriate values of the group-id variables, you can enter the commands (assuming six group-id variables)

      LET X1D = CROSS TABULATE GROUP ONE X1 X2 X3 X4 X5 X6
      LET X2D = CROSS TABULATE GROUP TWO X1 X2 X3 X4 X5 X6
      LET X3D = CROSS TABULATE GROUP THREE X1 X2 X3 X4 X5 X6
      LET X4D = CROSS TABULATE GROUP FOUR X1 X2 X3 X4 X5 X6
      LET X5D = CROSS TABULATE GROUP FIVE X1 X2 X3 X4 X5 X6
      LET X6D = CROSS TABULATE GROUP SIX X1 X2 X3 X4 X5 X6

    To restore the default, enter

      SET LET CROSS TABULATE EXPAND
Default:
    None
Synonyms:
    AVERAGE RANK
Related Commands:
    RANK = Rank the elements of a variable.
    SORT = Sort the elements of a variable.
    SORTC = Sort the elements of a variable and carry one or more variables along.
    CODE = Generate a coded variable.
    SEQUENCE = Generate a sequence of numbers.
Applications:
    Data Management
Implementation Date:
    2018/07
Program:
     
    . Step 1:   Read the data
    .
    dimension 20 columns
    set write decimals 2
    .
    skip 25
    read sheesle2.dat y x1 x2 x3 x4 x5
    let n = size y
    let xseq = sequence 1 1 6 for i = 1 1 n
    .
    . Step 2:   Execute the command
    .
    let yout = mean rank y xseq x2 x3
    print yout y xseq x2 x3
        
    The following output is returned
     
    ---------------------------------------------------------------------------
               YOUT              Y           XSEQ             X2             X3
    ---------------------------------------------------------------------------
               5.25          28.40           1.00           1.00           1.00
               1.75          21.90           2.00           1.00           1.00
               4.00          36.80           3.00           1.00           1.00
               2.75          19.20           4.00           1.00           1.00
               5.00          28.20           5.00           1.00           1.00
               2.25          26.60           6.00           1.00           1.00
               5.25          30.40           1.00           1.00           2.00
               1.75          25.10           2.00           1.00           2.00
               4.00          25.50           3.00           1.00           2.00
               2.75          21.50           4.00           1.00           2.00
               5.00          26.00           5.00           1.00           2.00
               2.25          21.90           6.00           1.00           2.00
               5.25          20.20           1.00           2.00           1.00
               1.75          14.30           2.00           2.00           1.00
               4.00          19.90           3.00           2.00           1.00
               2.75          22.50           4.00           2.00           1.00
               5.00          23.40           5.00           2.00           1.00
               2.25          18.50           6.00           2.00           1.00
               5.25          38.20           1.00           2.00           2.00
               1.75          12.80           2.00           2.00           2.00
               4.00          22.00           3.00           2.00           2.00
               2.75          22.50           4.00           2.00           2.00
               5.00          30.30           5.00           2.00           2.00
               2.25          17.70           6.00           2.00           2.00
        

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 11/08/2018
Last updated: 11/08/2018

Please email comments on this WWW page to alan.heckert@nist.gov.