RE: st: ereturn question [Stata 8]

 From "Nick Cox" To Subject RE: st: ereturn question [Stata 8] Date Wed, 4 May 2005 00:53:31 +0100

```Thanks. I'd forgotten that. The arbitrariness
w.r.t. e(b) and e(V) tempts me to post my hack.
The program is at the end.

. sysuse auto, clear

. qui regress displ weight

. eret li

matrices:
e(b) :  1 x 2
e(V) :  2 x 2

. matdi e(b)[1,1]
.10574552

. matdi e(V)[1,1]
.00003862

. mat foo = J(5,5,5)

. matdi foo[3,3]
5

. matdi foo [3,3]
examples: matdi e(b)[1,1]
matdi foo[3,2]
r(198);

program matdi
version 8
args matrix garbage
if "`garbage'" != "" {
di "{txt}examples: {cmd}matdi e(b)[1,1]" ///
"{break}{col 11}matdi foo[3,2]"
exit 198
}
local w = index("`matrix'", "[") - 1
if `w' == -1 error 198
local matname = substr("`matrix'", 1, `w')
local index = substr("`matrix'", `w' + 1,.)
tempname m
matrix `m' = `matname'
di as res `m'`index'
end

Nick
n.j.cox@durham.ac.uk

>
> Both Richard Williams <Richard.A.Williams.5@ND.edu> and Nick Cox
> <n.j.cox@durham.ac.uk> suggest the following:
>
> > mat nu = e(nu)
> > di nu[1,1]
>
> But they also ask if this is possible without defining a new
> matrix.  The
> answer is yes, use the -el()- matrix function:
>
> 	. di el(e(nu),1,1)
>
> Note that this is allowed with any matrix in e() except for
> e(b) and e(V);
> these two exceptions are special matrices that the el()
> function does not have
> variable for the
> elements of e(b) (and similarly use _se for the standard
> errors which are the
> square roots fo the diagonal elements of e(V)).

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