Statalist


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

Re: st: subsetting a matrix by rowname and column name


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: subsetting a matrix by rowname and column name
Date   Sun, 22 Mar 2009 10:20:08 +0000 (GMT)

--- On Sat, 21/3/09, Jacob Wegelin wrote:
> I'd ideally like to extract a scalar by row and column name,
> since this would be less error-prone.

You can get the indexes using the -rownumb()- and -colnumb()-
functions, and feed these to the -el()- function, like in the
example below

*------- begin example -----------
sysuse auto, clear
reg price mpg foreign
matrix v = e(V)
matrix list v
tempname foo
scalar `foo' = el(v,  ///
  rownumb(v,"_cons"), ///
  colnumb(v,"_cons"))
di `foo'
*------- end example --------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

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

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      

*
*   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