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 1 Auxiliary Chapter

VARIABLE TO MATRIX

Name:
    VARIABLE TO MATRIX
Type:
    LET Subcommand
Purpose:
    Convert a variable to a matrix.
Description:
    There may be times when it is desirable to convert a variable (i.e., a single column vector) to a matrix. This command provides a simple and convenient method for converting a variable to a matrix.

    With this command, you specify the desired number of rows in the matrix. Dataplot then divides the number of observations in the variable by the requested number of rows to obtain the number of columns in the matrix. If this division does not result in an integer value, the last column of the matrix will be filled with the "missing value". To set this value, enter

      SET STATISTIC MISSING VALUE <value>
Syntax:
    LET <m> = VARIABLE TO MATRIX <y> <nrow>
                            <SUBSET/EXPCEPT/FOR qualification>
    where <y> is the response variable;
                <nrow> is a parameter that specifies the number of rows for the matrix;
                <m> is a matrix that will contain the resulting matrix;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
Examples:
    LET M = VARIABLE TO MATRIX Y NROW
Note:
    By default, the matrix is created in row order from the variable. To create the variable in row order, enter the command

      SET VARIABLE TO MATRIX ROW

    To restore column order, enter

      SET VARIABLE TO MATRIX COLUMN
Note:
    It is also sometimes desirable to convert a matrix to a variable. This can be done with the command

      LET Y = MATRIX TO VARIABLE M

    where M is a previously created matrix.

Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Management
Implementation Date:
    2010/11
Program 1:
     
    LET Y = SEQUENCE 1 1 10
    LET NROW = 3
    .
    SET STATISTIC MISSING VALUE -1
    LET M = VARIABLE TO MATRIX Y NROW
    SET WRITE DECIMALS 1
    PRINT M
    DELETE M
    SET VARIABLE TO MATRIX ROW
    LET M = VARIABLE TO MATRIX Y NROW
    SET WRITE DECIMALS 1
    PRINT M
        
    The following output is generated.
            MATRIX M       --            3 ROWS
                           --            4 COLUMNS
    
     VARIABLES--M1             M2             M3             M4      
    
                1.0            4.0            7.0           10.0
                2.0            5.0            8.0           -1.0
                3.0            6.0            9.0           -1.0
     
     
    THE FORTRAN COMMON CHARACTER VARIABLE VARITO   HAS JUST BEEN SET TO ROW
     
     
            MATRIX M       --            3 ROWS
                           --            4 COLUMNS
    
     VARIABLES--M1             M2             M3             M4      
    
                1.0            2.0            3.0            4.0
                5.0            6.0            7.0            8.0
                9.0           10.0           -1.0           -1.0
        
Program 2:
     
    . Zarthan Company example from
    . Neter, Wasserman, Kutner, "Applied Linear Statistical Models"
    .
    .  Y = Sales
    .  X1  = Target Population (in thousands)
    .  X2  = Per Capita Discretionary Income (dollars)
    .
    DIMENSION 200 COLUMNS
    READ DISTRICT Y X1 X2
     1  162  274  2450
     2  120  180  3254
     3  223  375  3802
     4  131  205  2838
     5   67   86  2347
     6  169  265  3782
     7   81   98  3008
     8  192  330  2450
     9  116  195  2137
    10   55   53  2560
    11  252  430  4020
    12  232  372  4427
    13  144  236  2660
    14  103  157  2088
    15  212  370  2605
    END OF DATA
    FIT Y X1 X2
    .
    READ DPST4F.DAT  TEMP
    LET NROW = 3
    LET COV = VARIABLE TO MATRIX TEMP NROW
    SET WRITE DECIMALS -7
    PRINT COV
        
    The following output is generated.
            MATRIX COV     --            3 ROWS
                           --            3 COLUMNS
    
     VARIABLES--COV1           COV2           COV3
    
       0.5908062E+01  0.1009524E-02 -0.1970405E-02
       0.1009524E-02  0.3665626E-04 -0.3332548E-05
      -0.1970405E-02 -0.3332548E-05  0.9372445E-06
        

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