Examples (MATRIX DATA command)

Reading a Correlation Matrix

MATRIX DATA
    VARIABLES=ROWTYPE_ SAVINGS POP15 POP75 INCOME GROWTH.
BEGIN DATA
MEAN 9.6710 35.0896 2.2930 1106.7784 3.7576
STDDEV 4.4804 9.1517 1.2907 990.8511 2.8699
N 50 50 50 50 50
CORR 1
CORR -.4555 1
CORR .3165 -.9085 1
CORR .2203 -.7562 .7870 1
CORR .3048 -.0478 .0253 -.1295  1
END DATA.
  • The variable ROWTYPE_ is specified on VARIABLES. ROWTYPE_ values are included in the data.
  • No other specifications are required.

MATRIX DATA with DISCRIMINANT

 MATRIX DATA VARIABLES=WORLD ROWTYPE_ FOOD APPL SERVICE RENT
   /FACTORS=WORLD.
 BEGIN DATA
 1 N      25 25 25 25
 1 MEAN   76.64 77.32 81.52 101.40
 2 N      7 7 7 7
 2 MEAN   76.1428571 85.2857143 60.8571429 249.571429
 3 N      13 13 13 13
 3 MEAN   55.5384615 76 63.4615385 86.3076923
 . SD     16.4634139 22.5509310 16.8086768 77.1085326
 . CORR   1
 . CORR   .1425366 1
 . CORR   .5644693 .2762615 1
 . CORR   .2133413 -.0499003 .0417468 1
 END DATA.
 
 DISCRIMINANT GROUPS=WORLD(1,3)
   /VARIABLES=FOOD APPL SERVICE RENT /METHOD=WILKS /MATRIX=IN(*).
  • MATRIX DATA is used to generate a active dataset that DISCRIMINANT can read. DISCRIMINANT reads the mean, count (unweighted N), and N (weighted N) for each cell in the data, as well as the pooled values for the standard deviation and correlation coefficients. If count equals N, only N needs to be supplied.
  • ROWTYPE_ is specified on VARIABLES to identify record types in the data. Though CONTENTS and CELLS can be used to identify record types and distinguish between within-cells data and pooled values, it is usually easier to specify ROWTYPE_ on VARIABLES and enter the ROWTYPE_ values in the data.
  • Because factors are present in the data, the continuous variables (FOOD, APPL, SERVICE, and RENT) must be specified last on VARIABLES and must be last in the data.
  • The FACTORS subcommand identifies WORLD as the factor variable.
  • BEGIN DATA immediately follows MATRIX DATA.
  • N and MEAN values for each cell are entered in the data.
  • ROWTYPE_ values for the pooled records are SD and COR. MATRIX DATA assigns the values STDDEV and CORR to the corresponding vectors in the matrix. Records with pooled information have the system-missing value (.) for the factors.
  • The DISCRIMINANT procedure reads the data matrix. An asterisk (*) is specified as the input file on the MATRIX subcommand because the data are in the active dataset.

MATRIX DATA with REGRESSION

MATRIX DATA VARIABLES=SAVINGS POP15 POP75 INCOME GROWTH
  /CONTENTS=MEAN SD N CORR /FORMAT=UPPER NODIAGONAL.

BEGIN DATA
9.6710 35.0896 2.2930 1106.7784 3.7576
4.4804 9.1517 1.2908 990.8511 2.8699
50 50 50 50 50
-.4555 .3165 .2203 .3048
-.9085 -.7562 -.0478
 .7870 .0253
-.1295
END DATA.
 
REGRESSION MATRIX=IN(*) /VARIABLES=SAVINGS TO GROWTH
  /DEP=SAVINGS /ENTER.
  • MATRIX DATA is used to generate a matrix that REGRESSION can read. REGRESSION reads and writes matrices that always contain the mean, standard deviation, N, and Pearson correlation coefficients. Data in this example do not have ROWTYPE_ values, and the correlation values are from the upper triangle of the matrix without the diagonal values.
  • ROWTYPE_ is not specified on VARIABLES because its values are not included in the data.
  • Because there are no ROWTYPE_ values, CONTENTS is required to define the record types and the order of the records in the file.
  • By default, MATRIX DATA reads values from the lower triangle of the matrix, including the diagonal values. FORMAT is required in this example to indicate that the data are in the upper triangle and do not include diagonal values.
  • BEGIN DATA immediately follows the MATRIX DATA command.
  • The REGRESSION procedure reads the data matrix. An asterisk (*) is specified as the input file on the MATRIX subcommand because the data are in the active dataset. Since there is a single vector of N’s in the data, missing values are handled listwise (the default for REGRESSION).

MATRIX DATA with ONEWAY

 MATRIX DATA VARIABLES=EDUC ROWTYPE_ WELL /FACTORS=EDUC.
 BEGIN DATA
 1 N 65
 2 N 95
 3 N 181
 4 N 82
 5 N 40
 6 N 37
 1 MEAN 2.6462
 2 MEAN 2.7737
 3 MEAN 4.1796
 4 MEAN 4.5610
 5 MEAN 4.6625
 6 MEAN 5.2297
 . MSE 6.2699
 . DFE 494
 END DATA.
 
 ONEWAY WELL BY EDUC /MATRIX=IN(*)
  • One of the two types of matrices that the ONEWAY procedure reads includes a vector of frequencies for each factor level, a vector of means for each factor level, a record containing the pooled variance (within-group mean square error), and the degrees of freedom for the mean square error. MATRIX DATA is used to generate an active dataset containing this type of matrix data for the ONEWAY procedure.
  • ROWTYPE_ is explicit on VARIABLES and identifies record types.
  • Because factors are present in the data, the continuous variables (WELL) must be specified last on VARIABLES and must be last in the data.
  • The FACTORS subcommand identifies EDUC as the factor variable.
  • MSE is entered in the data as the ROWTYPE_ value for the vector of square pooled standard deviations.
  • DFE is entered in the data as the ROWTYPE_ value for the vector of degrees of freedom.
  • Records with pooled information have the system-missing value (.) for the factors.