Reputation: 740
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!
Upvotes: 9
Views: 3849
Reputation: 761
This is possible, but you will have to edit the source code of the stargazer function:
trace(stargazer:::.stargazer.wrap, edit = T)
.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 <- "]"
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
Upvotes: 10
Reputation: 21
A workaround is to capture the stargazer output and edit it. Here is an example where I save the stargazer output to a file, and then edit out "t = " from that file.
stargazer.save <- function(f.out, ...) {
# This is a wrapper function for saving stargazer output to file
output <- capture.output(stargazer(...))
cat(paste(output, collapse = "\n"), "\n", file=f.out, append=TRUE)
}
#save stargazer output (to e.g. a tex file)
stargazer.save(outfile, model.fit, report = "vc*t")
# read file back into R
u = readChar(outfile, file.info(outfile)$size)
# replace "t = " with a blank space
u = gsub("t = ","", u, ignore.case = F)
#write back to file
cat(u, file = outfile, append = F)
Upvotes: 2