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 <[email protected]>
To   [email protected]
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 <[email protected]> wrote:
Kam Kup <[email protected]> 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 <[email protected]> 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
[email protected]
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index