【问题标题】:Exporting R output into Latex - Stargazer for non suported objects将 R 输出导出到 Latex - 不支持对象的 Stargazer
【发布时间】:2016-01-28 10:55:34
【问题描述】:

我正在使用 frontier 包估计 R 中的模型,我需要将结果导出到 Latex 中。输出与lm 回归非常相似[见下文],但stargazer 不支持frontier 对象将它们导出到Latex 代码中。有没有办法解决这个问题?任何的想法? *我也在调查texregapsrtable,到目前为止没有成功。

frontier 回归输出示例:

【问题讨论】:

标签: r latex stargazer texreg


【解决方案1】:

我不太了解如何让stargazer 输出不支持的模型,但是您可以使用 broom 包中的tidy 方法将基本输出转换为与xtableknitr::kable 兼容的格式,或pixiedust

library(broom)
library(frontier)

# example included in FRONTIER 4.1 (cross-section data)
data( front41Data )

# Cobb-Douglas production frontier
cobbDouglas <- sfa( log( output ) ~ log( capital ) + log( labour ),
                    data = front41Data )
tidy(cobbDouglas, conf.int = TRUE)
broom:::tidy.lm(cobbDouglas)

          term  estimate  std.error statistic      p.value
1  (Intercept) 0.5616193 0.20261685  2.771829 5.574228e-03
2 log(capital) 0.2811022 0.04764337  5.900132 3.632107e-09
3  log(labour) 0.5364798 0.04525156 11.855499 2.015196e-32
4      sigmaSq 0.2170003 0.06390907  3.395454 6.851493e-04
5        gamma 0.7972069 0.13642438  5.843581 5.109042e-09

对于汇总统计信息,您需要编写自己的 glance 方法,因为 frontier 对象与 broom:::glance.lm 不兼容。

但我认为最终的结果是,如果你想模仿观星者的输出,你将不得不做一些预处理工作。

由于我今天感到雄心勃勃,这里有一个用于边界对象的 tidy 方法。

tidy.frontier <- function(x, conf.int = FALSE, conf.level = .95,
                          exponentiate = FALSE, quick = FALSE, ...)
{
  broom:::tidy.lm(x, conf.int = conf.int, conf.level = conf.level,
                  exponentiate = exponentiate, quick = quick, ...)
}


# example included in FRONTIER 4.1 (cross-section data)
data( front41Data )

# Cobb-Douglas production frontier
cobbDouglas <- sfa( log( output ) ~ log( capital ) + log( labour ),
                    data = front41Data )
tidy(cobbDouglas, conf.int = TRUE)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-24
    • 2023-04-04
    • 1970-01-01
    • 2013-10-20
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 2018-01-01
    相关资源
    最近更新 更多