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

CORRELATION MATRIX

Name:
    CORRELATION MATRIX (LET)
Type:
    Let Subcommand
Purpose:
    Compute the correlation matrix of a matrix.
Description:
    The correlation matrix computes the correlation coefficients of the columns of a matrix. That is, row i and column j of the correlation matrix is the correlation between column i and column j of the original matrix. Note that the diagonal elements of the correlation matrix will be 1 (since they are the correlation of a column with itself). The correlation matrix is also symmetric since the correlation of column i with column j is the same as the correlation of column j with column i.

    Alternatively, you can compute the CDF or the p-value for the correlation coefficient (i.e., to see if the correlation coefficient is significantly different than zero).

    To see the formulas for the correlation coefficient and the CDF and p-values, enter

Syntax 1:
    LET <mat2> = CORRELATION MATRIX <mat1>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat1> is a matrix for which the correlations are to be computed;
                <mat2> is a matrix where the resulting correlations are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional and rarely used in this context.
Syntax 2:
    LET <mat2> = CORRELATION CDF MATRIX <mat1>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat1> is a matrix for which the correlation CDF's are to be computed;
                <mat2> is a matrix where the resulting correlation CDF's are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional and rarely used in this context.

    This syntax computes the CDF of the correlation coefficient.

Syntax 3:
    LET <mat2> = CORRELATION PVALUE MATRIX <mat1>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mat1> is a matrix for which the correlation p-value's are to be computed;
                <mat2> is a matrix where the resulting correlation p-values's are saved;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional and rarely used in this context.

    This syntax computes the p-value of the correlation coefficient.

Examples:
    LET C = CORRELATION MATRIX A
Note:
    By default, the correlation matrices are computed on the columns. That is, element (i,j) of the correlation matrix is the correlation between column i and column j of the input matrix.

    To specify a correlation matrix based on rows rather than columns, enter the command

      SET MATRIX CORRELATION DIRECTION ROW

    To reset column based correlations, enter

      SET MATRIX CORRELATION DIRECTION COLUMN
Note: Note:
    Matrices are created with either the READ MATRIX command or the MATRIX DEFINITION command. Enter HELP MATRIX DEFINITION and HELP READ MATRIX for details.
Note:
    The columns of a matrix are accessible as variables by appending an index to the matrix name. For example, the 4x4 matrix C has columns C1, C2, C3, and C4. These columns can be operated on like any other DATAPLOT variable.
Note:
    The maximum size matrix that DATAPLOT can handle is set when DATAPLOT is built on a particular site. The default maximums are 100 columns and 100 rows.
Note:
    The September 2016 version of Dataplot added the following commands

      SET CORRELATION ABSOLUTE VALUE <ON/OFF>
      SET CORRELATION PERCENTAGE VALUE <ON/OFF>
      SET CORRELATION DIGITS <VALUE>

    These commands are typically used when plotting the correlation values. Specifically, the first command allows you to specify the absolute value of the correlation (useful when you are trying to identify significant correlation regardless of whether it is a positive or a negative correlation). The second command specifies the correlation as a percentage value (e.g., a correlation of 0.91 would be given as 91.0). The third command specifies how many digits to store for the correlation.

Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Linear Fitting
Implementation Date:
    87/10
    2002/07: Support for Winsorized correlation, rank correlation, and biweight mid-correlation
    2004/11: Support for Kendell tau correlation and for row based correlations
    2012/06: Added support for cdf and p-values
    2016/09: Added SET CORRELATION ABSOLUTE VALUE
    2016/09: Added SET CORRELATION PERCENTAGE VALUE
    2016/09: Added SET CORRELATION DIGITS
Program:
     
    .  This data is from page 202 of
    .
    .  Peavy, Bremer, Varner, Hogben (1986), "OMNITAB 80:
    .  An Interpretive System for Statistical and Numerical
    .  Data Analysis," NBS Special Publication 701.
    .
    .  Original source of the data is from
    .  Draper and Smith (1981), "Applied Regression Analysis",
    .  Wiley, p. 373.
    .
    dimension 40 columns
    .
    read matrix m
    42.2  11.2  31.9  167.1
    48.6  10.6  13.2  174.4
    42.6  10.6  28.7  160.8
    39.0  10.4  26.1  162.0
    34.7   9.3  30.1  140.8
    44.5  10.8   8.5  174.6
    39.1  10.7  24.3  163.7
    40.1  10.0  18.6  174.5
    45.9  12.0  20.4  185.7
    end of data
    .
    set write decimals 4
    let corr = correlation matrix m
    print corr
        
    The following output is generated.
            MATRIX CORR    --            4 ROWS
                           --            4 COLUMNS
    
     VARIABLES--CORR1          CORR2          CORR3          CORR4   
    
             1.0000         0.6837        -0.6160         0.8018
             0.6837         1.0000        -0.1725         0.7680
            -0.6160        -0.1725         1.0000        -0.6287
             0.8018         0.7680        -0.6287         1.0000
        

Privacy Policy/Security Notice
Disclaimer | FOIA

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

Date created: 01/23/2013
Last updated: 09/27/2016

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