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

MATRIX PARTITION STATISTIC

Name:
    MATRIX PARTITION STATSITIC (LET)
Type:
    Let Subcommand
Purpose:
    Compute a user specified statistic for either equi-spaced sub-matrices or arbitrary sub-matrices of a matrix.
Description:
    Previous versions of Dataplot allowed you to compute various column or row statistics (HELP MATRIX COLUMN STATISTIC or HELP MATRIX ROW STATISTIC for details). This capability has been extended to the case where the matrix is divided into equi-sized partitions and the specified statistic is computed in each of these partitions.

    Note that this command returns a matrix of statistic values.

    For this command, you specify the number of rows and columns for each of the sub-matrices. Dataplot starts the partitioning with position 1,1 of the original matrix.

    For example, if you have a matrix with 5 rows and 5 columns and you specify sub-matrices with 2 rows and 2 columns, the following partitioning will be performed:

              Matrix 1,1      Matrix 1,2    Matrix 1,3
               1   2           3   4         5
               6   7           8   9        10
       
              Matrix 2,1      Matrix 2,2    Matrix 2,3
              11  12          13  14        15
              16  17          18  19        20
       
              Matrix 3,1      Matrix 3,2    Matrix 3,3
              21  22          23  24        25
          

    A 3x3 matrix of computed statistics will be returned.

    This command was extended to the case of unequal partitions where the partitions need not be contiguous. For this case, we define two vectors. The first corresponds to the rows of the matrix while the second corresponds to the number of columns in the matrix. The elements of these two vectors identify which partition each element of the original matrix belongs to. For the 5x5 example above, suppose we want rows 1, 3, and 5 and columns 1, 4, and 5 to belong to partition 1 and rows 2 and 4 and columns 2 and 3 to belong to partition 2, we would create the following vectors:

              row vector          column vector
              ----------          -------------
                 1                      1 
                 2                      2 
                 1                      2 
                 2                      1 
                 1                      1 
          
    This results in the following partitioning:

              Matrix 1,1      Matrix 1,2
               1   4   5       2   3
              11  14  15      12  13
              21  24  25      22  23
      
              Matrix 2,1      Matrix 2,2
               6   8   9       7   8
              16  19  20      17  18
          
    One possible application of this case is to compute statistics for grouped data (you can do this explicitly for the mean and standard deviation using the MATRIX GROUP MEAN and MATRIX GROUP SD commands, but this command allows it for a broader range of statistics).
Syntax 1:
    LET <mout> = MATRIX PARTITION <stat> <mat> <nrow> <ncol>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat> is a matrix for which the statistic is to be computed;
                <stat> is the desired statistic to compute;
                <nrow> is the number of rows in each sub-matrix;
                <ncol> is the number of columns in each sub-matrix;
                <mout> is a matrix where the computed statistics are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    The specified statistic can be any of the following:

      MEAN, MIDMEAN, MEDIAN, TRIMMED MEAN, WINSORIZED MEAN,
      GEOMETRIC MEAN, HARMONIC MEAN, HODGES LEHMAN,
      BIWEIGHT LOCATION,
      SUM, PRODUCT,
      STANDARD DEVIATION, STANDARD DEVIATION OF MEAN,
      VARIANCE, VARIANCE OF THE MEAN,
      TRIMMED MEAN STANDARD ERROR,
      AVERAGE ABSOLUTE DEVIATION (or AAD),
      MEDIAN ABSOLUTE DEVIATION (or MAD),
      IQ RANGE, BIWEIGHT MIDVARIANCE, BIWEIGHT SCALE,
      PERCENTAGE BEND MIDVARIANCE,
      WINSORIZED VARIANCE, WINSORIZED STANDARD DEVIATION,
      RELATIVE STANDARD DEVIATION, RELATIVE VARIANCE (or
      COEFFICIENT OF VARIATION),
      RANGE, MIDRANGE, MAXIMUM, MINIMUM, EXTREME,
      LOWER HINGE, UPPER HINGE, LOWER QUARTILE, UPPER QUARTILE,
      <FIRST/SECOND/THIRD/FOURTH/FIFTH/SIXTH/SEVENTH/EIGHTH/ NINTH/TENTH> DECILE,
      PERCENTILE, QUANTILE, QUANTILE STANDARD ERROR,
      SKEWNESS, KURTOSIS, NORMAL PPCC,
      AUTOCORRELATION, AUTOCOVARIANCE,
      SINE FREQUENCY, SINE AMPLITUDE,
      CP, CPK, CNPK, CPM, CC,
      EXPECTED LOSS, PERCENT DEFECTIVE,
      TAGUCHI SN0 (or SN), TAGUCHI SN+ (or SNL),
      TAGUCHI SN- (or SNS), TAGUCHI SN00 (or SN2)
    This syntax is for the case where the partitions are equi-spaced and contiguous.
Syntax 2:
    LET <mout> = MATRIX PARTITION <stat> <mat> <tagrow> <tagcol>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat> is a matrix for which the statistic is to be computed;
                <stat> is the desired statistic to compute;
                <tagrow> is a vector that specifies which partition each row of the matrix belongs to;
                <tagcol> is a vector that specifies which partition each column of the matrix belongs to;
                <mout> is a matrix where the computed statistics are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax is for the case where the partitions need not be equi-spaced or contiguous. The list of supported statistics is the same as for syntax 1.

Examples:
    LET MOUT = MATRIX PARTITION MEAN M 5 5
    LET MOUT = MATRIX PARTITION MEDIAN M 10 5
    LET MOUT = MATRIX PARTITION SD M 2 2
Note:
    Matrices can be created with the READ MATRIX, CREATE MATRIX, and MATRIX DEFINITION commands. Enter HELP MATRIX DEFINITION, HELP READ MATRIX, and HELP CREATE MATRIX for details.
Note:
    Row and column statistics for a matrix can be computed using the MATRIX ROW STATISTIC and MATRIX COLUMN STATISTIC commands. Enter HELP MATRIX ROW STATISTIC and HELP MATRIX COLUMN STATISTIC for details.

    Statistics for all elements of a matrix can be computed with the MATRIX GRAND STATISTIC command. Enter HELP MATRIX GRAND STATISTIC for details.

Default:
    None
Synonyms:
    None
Related Commands:
    MATRIX COLUMN STATISTIC = Compute column statistics for a matrix.
    MATRIX ROW STATISTIC = Compute row statistics for a matrix.
    MATRIX GRAND STATISTIC = Compute statistics for all elements of a matrix.
    MATRIX COLUMN DIMENSION = Dimension maximum number of columns for Dataplot matrices.
Reference:
    "Applied Multivariate Statistical Analysis", Third Edition, Johnson and Wichern, Prentice-Hall, 1992.
Applications:
    Multivariate Analysis
Implementation Date:
    2005/6
    2005/7: Extended to case where partitions need not be equi-spaced or contiguous.
Program 1:
     
    READ MATRIX DAT M
    1 2 3 4
    5 6 7 8
    9 10 11 12
    13 14 15 16
    END OF DATA
    .
    LET MATMEAN = MATRIX PARTITION MEAN M 2 2
    LET MATSD   = MATRIX PARTITION SD   M 2 2
    LET MATSUM  = MATRIX PARTITION SUM  M 2 2
        
Program 2:
     
    dimension 50 columns
    skip 25
    read iris.dat y1 y2 y3 y4 x
    let m = create matrix y1 y2 y3 y4
    .
    let coltag = data 1 2 3 4
    .
    let matmed = matrix partition median m x coltag
    set write decimals 2
    print matmed
    
        

Date created: 6/30/2005
Last updated: 8/11/2005
Please email comments on this WWW page to alan.heckert@nist.gov.