Hi, all,
I'm struggling with an spss syntax issue. I need to perform some basic analyses on a saved covariance matrix. I can't for the life of me get this to work under normal syntax or within matrix-end matrix syntax. I've got covariance matrices (of varying size). They're saved as spss saved data files; the only data in the files are the actual covariance matrix data (variables labelled var1, var2, …vark, in the spss variable view but NOT as a column in the data set). For the purposes of what I need to get, I don't actually need the N. ALL I need to do is get the sum of variances (i.e., diagonal elements) and sum of covariances (i.e., one set of the symmetrical half-diagonal elements) from the data sets (I have a few data sets but doing them one at a time is fine). I can't get it to work at all trying syntax commands or using matrix-end matrix syntax (I'm not posting my attempts at doing it b/c they've all failed completely so I'm sure I'm doing something fundamental, not nuanced, wrong). I think I'm doing something wrong especially in trying to get the syntax to use a data file rather than a matrix written into the syntax (all examples I found used the latter). I'm sure there's a straightforward way of doing this that someone can help me out with! :-) Thanks, Mike ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
GET FILE "your matrix which is saved as an SPSS system file".
MATRIX. GET X /FILE=* /VARIABLES ALL. COMPUTE nr=NROW(X). COMPUTE nc=NCOL(X). PRINT nr. PRINT nc. COMPUTE SUMVAR=0. COMPUTE SUMCOV=0. LOOP I=1 TO nr. + LOOP J=1 TO I. + DO IF (I EQ J). + COMPUTE SUMVAR=SUMVAR+X(I,J). + ELSE. + COMPUTE SUMCOV=SUMCOV+X(I,J). + END IF. + END LOOP. END LOOP. PRINT SUMVAR. PRINT SUMCOV. END MATRIX.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
Here is another version which exploits built in functions of MATRIX language.
MATRIX. GET X /FILE=* /VARIABLES ALL. COMPUTE SUMVAR=TRACE(X). COMPUTE SUMCOV=(MSUM(X)-SUMVAR)/2. PRINT SUMVAR. PRINT SUMCOV. END MATRIX.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |