
From  "Rodrigo A. Alfaro" <raalfaroa@gmail.com> 
To  <statalist@hsphsun2.harvard.edu> 
Subject  Re: st: Mata subscripts on the left of an assignment 
Date  Wed, 28 Feb 2007 17:42:31 0500 
Hello Statalisters!
Not exactly to the topic, but hopefully close enough to avoid starting a new thread.
Can anybody clarify why can't I use subscripts after a call to e(something)?
Example:

. mat l e(b)
e(b)[1,2]
bywibs _cons
y1 .70162747 38.106444
. mat A=e(b)[1,1]
invalid syntax
r(198);
. mat B=e(b)
. mat A=B[1,1]
. mat l A
symmetric A[1,1]
c1
r1 .70162747

This is definitely not a bug, since intuitively e( ) is a function, but why such a behaviour with subscripts is not supported?
Is there a shorter way to extract a vector, etc from the estimates without using a temporary matrix? (in this example matrix B).
Regards,
Sergiy
 Original Message  From: "Ben Jann" <ben.jann@gmail.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Wednesday, February 28, 2007 10:29 PM
Subject: Re: st: Mata subscripts on the left of an assignment
*Cool. I stumbled over that too some time ago and thought I was just too stupid to understand it. ben On 2/28/07, William Gould, Stata <wgould@stata.com> wrote:Tom Palmer <tmp8@leicester.ac.uk> ended a long posting with,
> Is Mata behaving incorrectly in code example 2 or is this my
> misunderstanding?
Mata is misbehaving in example 2. I have just listed the problem as a bug.
Where the bug lies, however, may not be where Tom expects.
Example 2 in Tom's posting was
: y = (7\1\6\5)
: p = order(y,1)
: y = y[p]
: y[p] = y
: y
y should return unchanged, but it doesn't. Tom starts with
(7\1\6\5) and ends up with (1\1\6\1). The line that caused
the problem was
: y[p] = y
Tom asked, "Is Mata (incorrectly?) processing subscripts on the left of an
assignment on an element by element basis"?
No. The LHS y[p] logic is fine. The problem is that y appeared on
the RHS of the assignment, too, and as Mata executed the y[p] from y,
the RHS changed as Mata filled in the left. As a demonstration,
substitute for the following

y[p] = y x = y
y[p] = x

The substitution will work, yet both should be equivalent.
We will fix Mata so that y[p]=y works.
 Bill
wgould@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/
* * 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–2016 StataCorp LP  Terms of use  Privacy  Contact us  What's new  Site index 