Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: RE: create local from element of matrix e(b)


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: RE: create local from element of matrix e(b)
Date   Thu, 14 Oct 2010 14:37:17 -0500

On Thu, Oct 14, 2010 at 12:17 PM, Nick Cox <[email protected]> wrote:
> I am trying to create a local that equals an element of matrix e(b) produced by Stata following xtreg, fe. In fact, I am trying to get the first element.
>
> Here is what I did:
>
> quietly xtreg mdepc wavedi mdis_coh, fe
> . matrix list e(b)
> e(b)[1,3]
>       wavedi   mdis_coh      _cons
> y1  .24873096  .34650713  .83985765

If you don't know the name ahead, but know this is the first element,
then the one-liner is

mata : st_local( "dif", strofreal( st_matrix("e(b)")[1,1] ) )

You'd expect there should be fewer parentheses...

> . local dif = el(e(b), 1,1)
> matrix operators that return matrices not allowed in this context
> r(509);

That this solution does not work is annoying. -el()- is described as a
function returning a scalar in the documentation, but in this context
it only works if you assign the result to a matrix. With the named
matrices, the issue does not arise, though, so the problem is entirely
in the pseudo-function e(b).

-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index