| Date: | Fri, 23 Jul 2004 12:27:55 +0200 |
| Reply-To: | Dirk Enzmann <dirk.enzmann@jura.uni-hamburg.de> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | Dirk Enzmann <dirk.enzmann@jura.uni-hamburg.de> |
| Subject: | Re: Covariance matrix |
|
| Content-Type: | text/plain; charset=us-ascii; format=flowed |
Betty,
Try the following macro (available at:
http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Software/Enzmann_Software.html
Enzmann_Software
# --------------------------------------------------------------
DEFINE CovMat ( Vars !CharEnd ('/')
/OutFile !CMDEnd).
/* -------------------------------------------------------------- */
/* --- MACRO to export covariance matrix of variables 1..p --- */
/* -------------------------------------------------------------- */
/* To use this macro the list of variables must be specified */
/* together with the (path and) name of the covariance matrix to */
/* be written. */
/* A lower triangular matrix of variances and covariances of the */
/* variables will be written to the text-file specified, based on */
/* listwise deletion of missing cases. */
/* Example: */
/* You want to write out the covariance matrix of the variables */
/* x1, x2, x25, x49 into file C:/STATIST/TEST.COV. The respective */
/* macro-procedure CovMat is called by: */
/* */
/* CovMat Vars = x1,x2,x25,x49 */
/* /OutFile = 'c:\statist\test.cov'. */
matrix.
get X
/file = *
/variables = !vars
/missing = omit.
compute D = X-(Make(NRow(X),1,1)*(CSum(X)/NRow(X))).
compute COV = SSCP(D)/(NRow(X)-1).
compute s_2_mean = (msum(diag(cov)))/ncol(cov).
print NRow(X)
/title"N(Cases):"
/FORMAT = "F10.0".
print NCol(X)
/title"P(Variables):"
/FORMAT = "F10.0".
print t(diag(cov))
/title"Variances:"
/FORMAT = "F7.3".
print CMin(diag(cov))
/Title"Min variance:"
/Format= "F9.5".
print CMax(diag(cov))
/Title"Max variance:"
/FORMAT = "F9.5".
print s_2_mean
/title"Mean variance:"
/FORMAT = "F9.5".
print det(cov)
/title"Determinant(cov):"
/Format = "F14.10".
WRITE cov
/OUTFILE = !outfile
/FIELD = 1 TO 80
/MODE = TRIANGULAR.
END MATRIX.
!EndDefine.
/* --------------------------------------------------------- */.
/* The macro is called by: */.
/* */.
/* CovMat VARS = variables */.
/* /OUTFILE = 'filename'. */.
/* --------------------------------------------------------- */.
# --------------------------------------------------------------
Dirk
Thu, 22 Jul 2004 10:36:58 -0500 "Harris, Betty A." <bettyh@ou.edu> wrote:
> What's the easiest way to output a covariance matrix for use with AMOS?
--
*************************************************
Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Schlueterstr. 28
D-20146 Hamburg
Germany
phone: +49-040-42838.7498 (office)
+49-040-42838.4591 (Billon)
fax: +49-040-42838.2344
email: dirk.enzmann@jura.uni-hamburg.de
www:
http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html
*************************************************
|