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);
. type matdi.ado
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
[email protected]
Jeff Pitblado, StataCorp LP
>
> Both Richard Williams <[email protected]> and Nick Cox
> <[email protected]> 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
> access to, but you can use [eqname]_b[indepvarname] system
> 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/