Statalist


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

st: re: how to form a vector for each line


From   Christopher Baum <[email protected]>
To   [email protected]
Subject   st: re: how to form a vector for each line
Date   Thu, 15 Oct 2009 13:10:27 -0400

<>
Nick said

Some readers may find Martin's opening sentence a little puzzling, however. In Stata, as compared with Mata, there is no difficulty in setting up row or column vectors, which are just matrices with one row or column. In this sense, Stata has had the idea of vector for several versions now.

To be pedantic, Stata (as opposed to Mata) does not and never has had vectors. Vectors are ordered arrays with a *single* subscript. There is no way to create such an object in Stata. You can have matrices with one row or one column (or both) that look like vectors, but to use them you must include both a row subscript and a column subscript in the notation. In that annoying way, Stata's old matrix language does not allow vectors at all. Mata has the concept of a vector, and allows you to reference an element as nj[42] rather than nj[42,1] or nj[1,42]. IMHO this is a good reason to avoid the old matrix language when you can, as it unnecessarily complicates working with 'real' vectors such as e(b).

Kit Baum   |   Boston College Economics and DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming   |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata   |   http://www.stata-press.com/books/imeus.html

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