【问题标题】:Formatting Stata post-estimation results for LaTeX格式化 LaTeX 的 Stata 后估计结果
【发布时间】:2012-06-18 22:36:55
【问题描述】:

我想在 Stata 中编写一个 TeX 文件,其中包含一个四舍五入到最接近 0.001 的 p 值。由于 sutex、outtab 等没有内置的后估计结果功能,我尝试了很多类似

file write myfile %4z "`r(p)'"

gen temp = round( `r(p)',.001)
format temp %4.3f
sum temp, f
file write myfile " & `r(mean)'" 

有什么想法吗?

【问题讨论】:

    标签: latex stata


    【解决方案1】:

    这是一个将 t 检验中的 p 值写入文本文件的示例。 p 值四舍五入到小数点后三位。

    sysuse auto, clear
    ttest price, by(fore)
    file open myfile using "foo.txt", write replace
    file write myfile "price & " %5.3f (r(p)) " \\"
    file close myfile 
    type "foo.txt"
    

    我指定了5.3f 格式。第一个数字表示输出的宽度为 5。此宽度包括小数点。第二个数字表示小数点后面会有三位数字。如果您想了解有关此表示法以及您拥有的其他选项的更多信息,请查看help format

    r(p) 周围的括号表示将对该表达式进行评估并将结果写入文件。这在help file 中有解释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-30
      • 2023-03-28
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      相关资源
      最近更新 更多