[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"R.E. De Hoyos" <redeho@hotmail.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: RE: summing up matrix elements |

Date |
Tue, 8 Nov 2005 16:23:14 -0000 |

Dear Jamie and Nick,

Both your solutions work fine, thanks a lot. I though there was a non-mata matrix function similar to mata's -sum(C)-

Best regards,

Rafa

----- Original Message ----- From: "Nick Cox" <n.j.cox@durham.ac.uk>

To: <statalist@hsphsun2.harvard.edu>

Sent: Tuesday, November 08, 2005 3:28 PM

Subject: st: RE: summing up matrix elements

. mata : sum_r = (sum(C) - trace(C)) / 2

Nick n.j.cox@durham.ac.uk

R.E. De Hoyos

> 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).

* * 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/

* * 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/

**References**:**st: RE: summing up matrix elements***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: summing up matrix elements** - Next by Date:
**Re: st: predict returning incorrect values for mu following glm** - Previous by thread:
**st: RE: summing up matrix elements** - Index(es):

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