Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Calculate average elements matrix (below the diagonal )


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Calculate average elements matrix (below the diagonal )
Date   Tue, 11 Sep 2012 10:28:33 +0100

There are probably more elegant ways to do it, but this works:

sysuse auto
corr price mpg rep78
mata
C = st_matrix("r(C)")
mean(abs(select(vech(C), vech(C) :< 1)))


On Tue, Sep 11, 2012 at 9:34 AM, John Antonakis <[email protected]> wrote:

> I would like to calculate the average absolute correlations of a correlation
> matrix.  E.g.,
>
> sysuse auto
> corr price mpg rep78
> mat A = r(C)
> mat list A
>
> This returns the following three correlations below the diagonal:
>
> -.45594895 .00655327 .40234039
>
> Specifically, I would like to: obtain the average absolute values of the
> below-diagonal elements:
>
> i.e., dis (abs(-.45594895) + abs(.00655327) + abs(.40234039))/3
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index