Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Matrix subscripts using row and column names


From   vwiggins@stata.com (Vince Wiggins, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Matrix subscripts using row and column names
Date   Thu, 17 Jul 2003 16:33:30 -0500

Bill Gould <wgould@stata.com> explained to West Addison <wastata@yahoo.com>
why matrix expressions such as

        V["price","price"]

cannot be used in a scalar context.  While I agree complete with Bill's
explanation (I think I am required to by contract), West might be interested
in a "back door" way of evaluating the expression on one line.  Whereas the
matrix subscripting logic is geared toward efficiency, as Bill described, the
-rownumb()- and -columb()- functions are not so picky.  West's original
example,

    . generate sdif = dif / sqrt(V["price", "price"])

will not work.  However,

    . generate sdif = dif / sqrt(V[rownumb(V,"price"), colnumb(V,"price")])

will.


-- Vince
   vwiggins@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/



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