Besides displaying output in the results window, Stata stores results that you can use as inputs to subsequent commands. We have shown examples of using saved results in Writing Greek letters and other symbols in graphs and Ways to count the number of unique values in a variable where we used results stored in r(). In this post, we will use estimation results saved in e() after -regress- to generate a scalar (or a local macro) for coefficients and standard errors. (See note below)

**sysuse ***auto */* opens example data auto.dta */

**reg ***price mpg */* estimates the equation price = b0 + b1*mpg + e ; to display all saved results after -regress-, type “ereturn list” */

**matrix b**=e(b)

**matrix V**=e(V)

/* defines matrix **b** equal to the row vector of estimated coefficients, e(b); and matrix **V** equal to the variance-covariance matrix, e(V). */

**matrix list b **// or **matrix list** e(b)

**matrix list V **// or **matri list **e(V)

/* displays **b** and **V** */

**scalar ***c_mpg*=b[1,1]

**scalar ***se_mpg*=sqrt(V[1,1])

/* defines scalar* c_mpg* equal to element (1,1) of vector **b**; and defines scalar *se_mpg* equal to the square root of element (1,1) of matrix **V** */

**scalar list **/* displays *c_mpg* and *se_mpg* */

Alternatively, you may define ** ***c_mpg *and *se_mpg *as local macros instead of scalars:

**local ***c_mpg*=**b**[1,1]

**local ***se_mpg*=sqrt(**V**[1,1])

**display **“c_mpg= “`c_mpg' " ; se_mpg= "`

se_mpg’

Note: Where Stata saves the results depends on the type of command executed. Stata commands can be classified into 5 classes—r-, e-, s-, n-, and c-class commands:

r-class: general commands that do not require parameter estimation (example: -summarize-); results are stored in r()

e-class: parameter estimation commands (example: -regress-); results are stored in e()

s-class: programming commands that assist in parsing; results are stored in s()

n-class: commands that do not save other results except those that are explicitly generated (example: -generate-); no results stored

c-lass: stores system parameters and some constants (example: c(pi) returns the value of pi); values are stored in c() (try typing “creturn list”)

Filed under: Basic functions, Econometrics / Statistics, Mata / Matrix, Post-estimation Tagged: | coefficient, local macro, matrix, scalar, standard error

## Leave a Reply