我目前正准备一张与观星者合作的回归结果表。在此,我还想展示t统计量。为此,我使用以下简化规范,如http://jakeruss.com/cheatsheets/stargazer.html#report-t-statistics-or-p-values-instead-of-standard-errors
中所示stargazer(output, output2, type = "html",
report = "vc*t")
结果表报告t统计数据如下:
0.088
t = 5.822***
现在我的问题是:对每个模型和每个系数重复“t =”。这在某种程度上是多余的,并降低了表的可读性。
有没有办法只报告没有“t =”标签的t统计值?在括号中显示值非常棒。
谢谢!
答案 0 :(得分:3)
这是可能的,但你必须编辑观星者功能的源代码:
trace(stargazer:::.stargazer.wrap, edit = T)
.format.t.stats.left <- "t = "
和
.format.t.stats.right <- ""
并根据自己的喜好进行编辑,例如:
.format.t.stats.left <- "["
和.format.t.stats.right <- "]"
stargazer(model1, type = "text", report = "vc*t")
的观星者输出应如下所示:
=======================================================================
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
答案 1 :(得分:2)
解决方法是捕捉观星者输出并进行编辑。这是一个例子,我将观星者输出保存到文件中,然后编辑出来&#34; t =&#34;从那个文件。
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)