Statalist


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

Re: st: How to stack two correlation matrix tables into one big correlation matrix (lower and upper diagonal) table?


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: How to stack two correlation matrix tables into one big correlation matrix (lower and upper diagonal) table?
Date   Mon, 8 Feb 2010 00:05:40 -0800 (PST)

--- On Mon, 8/2/10, Kelvin Tan wrote:
> I would like to know if I can stack two correlation matrix
> tables into one big correlation matrix (("foreign=1") in
> lower diagonal and (foreign=0) in upper diagonal of the
> big correlation matrix table) .

Here is an example of how to do that without reporting any
stars/significance levels/confidence intervals. I don't know
how to add those.

*---------------- begin example --------------------
// check if -estout- is installed
// you can remove these two lines if you already know
// that -estout- is installed on your machine.
capt which estout
if _rc ssc inst estout

// get data
sysuse auto.dta, clear

// collect correlation matrices
correlate trunk weight length if foreign==1
matrix c1 = r(C)
correlate trunk weight length if foreign==0
matrix c2 = r(C)

// combine the matrices
mata
c1 = st_matrix("c1")
c2 = st_matrix("c2")
c = lowertriangle(c1) + uppertriangle(c2) - I(rows(c1))
st_matrix("c", c)
end  

// copy the row and column names
matrix rownames c = `: rownames c1'
matrix colnames c = `: colnames c1'

// display the result
esttab matrix(c, fmt(3)), compress tex 
*-------------------- end example ------------------------
( For more on how to use examples I sent to statalist see:
 http://www.maartenbuis.nl/stata/exampleFAQ.html )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index