Ordering variables in a nested regression table of asdoc in Stata

  • 8

Ordering variables in a nested regression table of asdoc in Stata

Category:asdoc,Blog Tags : 

In this blog entry, I shall highlight one important, yet less known, feature of the option keep() in nested regression tables of asdoc. If you have not used asdoc previously, this half-page introduction will put on fast track. And for a quick start of regression tables with asdoc, you can also watch this YouTube video.

 

Option keep()

There are almost a dozen options in controlling the output of a regression table in asdoc. One of them is the option keep(list of variable names). This option is primarily used for reporting coefficient of the desired variables. However, this option can also be used for changing the order of the variables in the output table. I explore these with relevant examples below.

 

1. Changing the order of variables

Suppose we want to report our regression variables in a specific order, we shall use option keep() and list the variable names in the desired order inside the brackets of option keep(). It is important to note that we have to list all variables which we want to report as omitting any variable from the list will cause asdoc to omit that variable from the output table.

 

An example

Let us use the auto dataset from the system folder and estimate two regressions. As with any other Stata command, we need to add asdoc to the beginning of the command line. We shall nest these regressions in one table, hence we need to use the option nest. Also, we shall use option replace in the first regression to replace any existing output file in the current directory. Let’s say we want to variables to appear in this order in the output file _cons trunk weight turn. Therefore, the variables are listed in this order inside the keep() option. The code and output file are shown below.

sysuse auto, clear
asdoc reg mpg turn, nest replace
asdoc reg mpg turn weight trunk, nest keep(_cons trunk weight turn)

 

 

2. Reporting only needed variables

Option keep is also used for reporting only needed variables, for example, we might not be interested in reporting coefficients of year or industry dummies. In such cases, we shall list the desired variable names inside the brackets of the keep() option. In the above example, if we wish to report only _cons trunk weight , we would just skip the variable turn from the keep option. Again, the variables will be listed in the order in which they are listed inside the keep option.  

sysuse auto, clear
asdoc reg mpg turn, nest replace
asdoc reg mpg turn weight trunk, nest keep(_cons trunk weight)

 

 

Off course, we could also have used option drop(turn) instead of option keep(_cons trunk weight) for dropping variable turn from the output table.

 


 


8 Comments

Fa

February 2, 2019at 3:52 pm

Two queries
1. Some time we are interested in F-Stat value and it’s P-Value. To identify the overall significance of model. Both asdoc and outreg do not report it in table. If you can guide please.
2. Can we add t-test or any other test for mean difference with in same regression table. For example, if we regress 5 portfolios and at last we are interested in testing mean difference of Port-1 and Port-5.

    Attaullah Shah

    February 2, 2019at 8:37 pm

    Fa:
    For your first query, I would refer you to the help file of asdoc, Section 4. Regressions, subsection 4.10 option stat(). You can use option stat() for reporting any statistic from the e() macro. These statistics are usually revealed by typing

    ereturn list

    after the regress command. The macro for F-statistic is e(F). So if you wish to report it with asdoc, you can use option stat(F). e.g,

    sysuse auto, clear
    asdoc reg mpg turn, nest  replace stat(F)
    asdoc reg mpg turn weight trunk, nest  stat(F) keep(_cons trunk weight)

     
    For your second query, I would refer you again to the help file of asdoc, Section 4, subsection 4.8, option add(). You can use option add() to add up to three lines of additional text and statistics. This option adds text legends to the bottom cells of the nested regression table. The text legends should be added in pairs of two, each one separated by a comma. So to add mean of a variable to the regression table, see how I use this option. First, I create the mean with sum command, write it to a local named as mean1, and then add additional text and the local in the add() option.

    sum mpg
    loc mean1 : di %9.0f = `r(mean)'
    asdoc reg mpg turn, nest  replace add(Mean price, `mean1')

    Right now this option needs some additional tweaks as it deletes decimal points, therefore, I have written the above macro with zero decimal points. I shall work on it sometime in future.

Paul Schumann

February 14, 2019at 7:16 pm

Dear Mr. Shah,
First of all, I’d like to thank you for introducing the asdoc package to Stata. This is a great addition and I used it successfully many times. However, there seems to be a problem with asdoc when using a mixed model for analyzing panel data. For some reason, it gives me an error message.

command “befristetwithin” is unrecognized

Befristetwithin is part of my analyses, which im trying to estimate as a random effect. I think there could be an issue with the highlighted part of my regression. Maybe asdoc does not know how to handle this part, since it involves some “unsual” signs. It would be great and i really appreciate it, if you could give me any advice on how to solve this issue.

my regression:

asdoc xtmixed Gluecklich c.befristetwithin befristetdumm_mean Changeinwork_mean ///
Changeinworkwithin c.Changeinworkwithin#c.befristetwithin arbeitsplatzsicherheit_mean ///
arbeitsplatzwithin Geschlechttest Alterwithinstandard Alterzentriertstandard  /// 
Verheiratetwithin Verheiratet_mean Kinderwithin Kinder_mean Gesundheitwithin ///
Gesundheit_mean Geschiedenwithin Geschieden_mean Widowwithin Widow_mean /// 
Einkommenwithin Einkommen_mean || PERSNR: befristetwithin  if Gluecklich>0, /// 
covariance(unstructured)

Kind Regards,
Paul Schumann

    Attaullah Shah

    February 14, 2019at 7:24 pm

    Dear Paul Schumann

    Thanks for the feedback. I have changed asdoc and uploaded a new version to SSC. Please install it by

    * For installation of the new version
    ssc install asdoc, replace

    I hope it will solve the problem. Please do cite asdoc in your research.

    In-text citation
    Tables were created using asdoc, a Stata program written by Shah (2018).

    Bibliography
    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.

Farah Zamir

March 5, 2019at 3:47 am

Hi Dr Shah

Can w replace tstat instead of standard errors while reporting our results in Stata?
I mean use “tstat in paranthesis” instead of “Standard errors are in parenthesis” ???????

    Attaullah Shah

    March 5, 2019at 7:17 am

    Farah Zamir
    The option rep(t) can be used for reporting t-statistics when making a nested regression table.

    sysuse auto, clear
    asdoc reg price mpg rep78, nest replace rep(t)

Bram Hogendoorn

April 15, 2019at 5:23 pm

Dear Mr. Shah,

Thank you for your dedicated introduction of asdoc. Its user friendlyness and concise helpfiles make it a great addition to Stata.

I have a question regarding the significance stars. When using the “eform” option of cloglog, the significance stars seem to be reported incorrectly. I think that this is because the regression coefficients are exponentiated while the standard errors are not; hence the stars are reported over the wrong franction – but this is just a guess.

It would be great if you could have a look at this. Thank you very much.

    Attaullah Shah

    April 15, 2019at 6:21 pm

    Dear Bram Hogendoorn
    Thanks for your kinds words and pointing out this bug. The problem occurs in cloglog regression when using option eform and nest together. I shall rectify the error soon.

Leave a Reply

one × 5 =