Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R stargazer package: eliminate "t =" label from reported test statistics

Tags:

r

stargazer

I am currently preparing a table of regression results with stargazer. In this, I also want to show the t-statistics. For that, I use the following simplified specification, as also shown in http://jakeruss.com/cheatsheets/stargazer.html#report-t-statistics-or-p-values-instead-of-standard-errors

stargazer(output, output2, type = "html",
      report = "vc*t")

The resulting table reports the t-statistics as follows:

0.088    
t = 5.822***

Now my question: the "t =" is repeated for each model and each coefficient. This is somehow redundant and reduces readability of the table.

Is there a way to only report the value for t-statistic without the "t =" label? It would be great to just show the value in parentheses.

Thanks!

like image 422
deca Avatar asked Mar 24 '17 09:03

deca


1 Answers

This is possible, but you will have to edit the source code of the stargazer function:

  1. Access the edit-screen of the stargazer function with trace(stargazer:::.stargazer.wrap, edit = T)
  2. Go to line 7103/7104 (may be different depending on your stargazer version, e.g., its now lines 7053 and 7054 for version 5.2.2. in April 2021) and look for .format.t.stats.left <- "t = " and .format.t.stats.right <- "" and edit it to your liking, e.g., .format.t.stats.left <- "[" and .format.t.stats.right <- "]"
  3. Confirm with "save".
  4. You will have to redo this step every time you restart your R session as the changes to the source code are only temporarily.

Your stargazer output of stargazer(model1, type = "text", report = "vc*t")should then look like the following:

=======================================================================
                                         Dependent variable:           
                              -----------------------------------------
                                           daily_invcount2             
                                              negative                 
                                              binomial                 
-----------------------------------------------------------------------
log(lag_raised_amount + 1)                    -0.466***                
                                              [-7.290]                 
                                                                       
lag_target1                                   -0.661***                
                                              [-7.680]                 
                                                                                                                                                              
Constant                                      -3.480**                 
                                              [-5.490]                 
               
-----------------------------------------------------------------------
Observations                                    6,513                  
Log Likelihood                                 -8,834                
theta                                     1.840*** (0.081)             
Akaike Inf. Crit.                              17,924                
=======================================================================
Note:                         + p<0.1; * p<0.05; ** p<0.01; *** p<0.001
like image 186
JNWHH Avatar answered Nov 01 '22 05:11

JNWHH