Re: Display a correlation matrix showing only the lower half triangular portion in spss

Posted by Bruce Weaver on
URL: http://spssx-discussion.165.s1.nabble.com/Display-a-correlation-matrix-showing-only-the-lower-half-triangular-portion-in-spss-tp5740696p5740697.html

This does what you ask for in an an example I generated.  

VECTOR x = x1 to x3.
LOOP # = 1 to 2.
 DO IF Rowtype_ EQ "CORR".
  IF x(#) EQ 1 OR MISSING(x(#)) x(#+1) = $SYSMIS.
 END IF.
END LOOP.
LIST.

Why do you want to do this though?  In the full example I tried (see below), the matrix data set no longer works as input to the REGRESSION command after changing values above the diagonal to SYSMIS.  

Here's the full example.  

NEW FILE.
DATASET CLOSE ALL.
MATRIX DATA
    VARIABLES=ROWTYPE_ x1 x2 x3.
BEGIN DATA
MEAN 9.6710 35.0896 2.2930
STDDEV 4.4804 9.1517 1.2907
N 50 50 50
CORR 1
CORR -.4555 1
CORR .3165 -.9085 1
END DATA.

REGRESSION MATRIX IN(*)
 /VARIABLES=x1 x2 x3
 /DEPENDENT=x1
 /METHOD=ENTER x2 x3.

* Change values above diagonal to SYSMIS.
VECTOR x = x1 to x3.
LOOP # = 1 to 2.
 DO IF Rowtype_ EQ "CORR".
  IF x(#) EQ 1 OR MISSING(x(#)) x(#+1) = $SYSMIS.
 END IF.
END LOOP.
LIST.

REGRESSION MATRIX IN(*)
 /VARIABLES=x1 x2 x3
 /DEPENDENT=x1
 /METHOD=ENTER x2 x3.



zhanggonwoo wrote
I want to display only one triangle of a correlation matrix
how can I enter the syntax?

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).