|
VARIABLE TO MATRIXName:
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
<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.
To restore column order, enter
where M is a previously created matrix.
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 |