the missing e(se) return matrix

December 8, 2009 at 4:52 am 2 comments

| Gabriel |

One of the weird things with Stata’s postestimation returns is that it gives you the betas no problem, but there’s no obvious return for the standard error. The closest thing it gives you is e(V), the variance-covariance matrix, which you have to process to get standard error.

sysuse auto, clear
reg weight foreign length
* save the return matrices
matrix betas=e(b)
matrix varcovar=e(V)
*take the root of the diagonal of var-covar
mata: st_matrix("se",sqrt(diagonal(st_matrix("varcovar")))')
*combine and label the beta & se vectors into a single matrix
matrix results=betas\se
matrix rowname results = beta se
matrix list results

(Note: I’ve just discovered the “sourcecode” WordPress format, which should avoid some previous problems I’ve had with putting code directly in posts].

Entry filed under: Uncategorized. Tags: .

Links The Cambridgiad

2 Comments

  • 1. PAC  |  December 8, 2009 at 5:51 am

    You can store the standard error using the _se[_cons], _se[x], etc commands which are similar to the _b[_cons]. For instance :

    qui reg y x
    di _b[_cons] /* display the constant */
    di _se[_cons] /* display the standard error fo the constant*/

    • 2. gabrielrossman  |  December 8, 2009 at 1:28 pm

      very useful, thanks. shame it doesn’t appear in the return list or ereturn list. depending on the purpose to which you’re putting it your technique of calling the se one variable at a time could be easier/more useful than calling and cleaning the var-covar matrix.


The Culture Geeks


%d bloggers like this: