Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: summing up matrix elements


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   st: summing up matrix elements
Date   Tue, 8 Nov 2005 14:47:09 -0000

Statalist,

Is there a way to to get a scalar containing the sum of the off-diagonal elements of a pre-defined matrix?

For instance, define matrix C as a correlation matrix. I want to know what is the sum of correlations between the various elements in C. Therefore I need the sum of all elements in C minus the sum of the diagonal elements (-trace(C)-) and finally divide it by 2 (I am assuming matric C is symetric).

Many thanks,

Rafa
________________________
R.E. De Hoyos
Faculty of Economics
University of Cambridge
CB3 9DE, UK
www.econ.cam.ac.uk/phd/red29/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index