Multivariate Statistical Techniques

Example Matrix Operations in SPSS


matrix.

***** define a matrix with the compute command****.

      ***** A is a 2 X 2 matrix********.
compute A={3,2;4,0}.

      ***** B is a 2 X 5 matrix*********.
compute B={1,3,0,5,7;2,4,3,3,3}.

      ***** C is a 2 X 2 matrix*********.
compute C={0,8;9,1}.

***** transpose B******.
compute Btrans=transpos(B).

****** Add *****.
compute AplusC=A+C.

***** multiply****.
compute AB=A*B.

***** inverse*****.
compute inverseA=inv(A).

***** determinant ***.
compute detA=det(A).

*******print the results ********.
print A /title "Matrix A".
print B /title "Matrix B".
print Btrans /title "B transpose".
print AplusC /title "A + B".
print AB /title "AB".
print inverseA /title "A inverse".
print detA /title "Det A".

end matrix.

Results 

Matrix
  
Run MATRIX procedure:

Matrix A
  3  2
  4  0

Matrix B
  1  3  0  5  7
  2  4  3  3  3

B transpose

  1  2
  3  4
  0  3
  5  3
  7  3

A + B
   3  10
  13   1

AB
   7  17   6  21  27
   4  12   0  20  28

A inverse
   .0000000000   .2500000000
   .5000000000  -.3750000000

Det A
 -8


Multivariate Course Web Page

Phil Ender, 27sep07