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   [email protected] (William Gould, Stata)
To   [email protected]
Subject   Re: st: Turn lower diagonal matrix into a symmetric matrix
Date   Mon, 05 Feb 2007 11:41:48 -0600

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/



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