0
votes

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?)

1
This is a forum for programmers, so as a programmer what is your strategy here? You could try cloning xthtaylor and modifying it, or work with what it does leave behind, as shown by ereturn list.Nick Cox
Thanks! This helped, I just had to do ereturn display, which showed the results again and then matrix tab = r(table) worked to get the results in a matrix.0livier1O1

1 Answers

2
votes

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.