Statalist The Stata Listserver


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

Re: st: Turn lower diagonal matrix into a symmetric matrix


From   Rachel <academicgirl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Turn lower diagonal matrix into a symmetric matrix
Date   Tue, 6 Feb 2007 10:30:45 -0500

Thanks to both of you.  This command (within mata) has saved me a lot of time.


Rachel

On 2/5/07, William Gould, Stata <wgould@stata.com> wrote:
Kam Kup <kamkupan@yahoo.com> wrote,

> I'm looking for a function that can turn a
> lower-triangular matrix into a symmetrical matrix by
> reflecting the lower triangular elements across the
> diagonal (without disturbing the original elements.)


and Maarten buis <maartenbuis@yahoo.co.uk> replied

> -help mata makesymmetric()-


Good answer if Kam is using Mata.  If he's using Stata's old matrix
language, here's how Kam could use Maarten's answer to implement a
solution:

        program makesymmetric
                version 9
                syntax name
                qui mat list `namelist'         // to make sure exists
                mata: st_replacematrix("`namelist'", ///
                      makesymmetric(st_matrix("`namelist'")))
        end

-- Bill
wgould@stata.com
*
*   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/



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