0livier1O1
0livier1O1

Reputation: 63

Convert a multilevel output from xthtaylor to a matrix in Stata

In Stata, after running the xthtaylor command, the command

matrix regtab = r(table) 

yields an empty matrix. I think this is because of the multilevel of the output of this command enter image description here Being new to Stata, I haven't found how to fix this. The purpose here is to extract the coeffecient and standard errors to add them to another output (as is done in the accepted solution of How do I create a table wth both plain and robust standard errors?)

Upvotes: 0

Views: 117

Answers (1)

Arthur Morris
Arthur Morris

Reputation: 1348

To expand on Nick's point: matrix regtab = r(table) gives you an empty matrix, because xthtaylor doesn't put anything into r(table).

To see this run the following example:

clear all // empties r(table) and everything else
webuse psidextract
* the example regression from `help xthtaylor`
xthtaylor lwage wks south smsa ms exp exp2 occ ind union fem blk ed, endog(exp exp2 occ ind union ed) constant(fem blk ed)

return list doesn't have anything in r(table), but ereturn list will show you that you have access to the coefficients through e(b) and the variance-covariance matrix through e(V).

You can assign these to their own matrices as follows:

matrix betas = e(b)
matrix varcovar = e(V)

Then you can use matrix commands (see help matrix) to manipulate these matrices.

As you discovered, ereturn display creates r(table) which appears quite convenient for your use. It's worth taking a look at help return for more information about the differences between the contents of return list and ereturn list.

Upvotes: 2

Related Questions