R观星功能产生的表未对齐 [英] R stargazer function produced table is not aligned

查看:39
本文介绍了R观星功能产生的表未对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个回归,所有变量名称都相同.

I have three regression and all variables name are identical.

reg1 <-lm(y〜x1 + x2 + x3 + x4,data = data1)

reg2< -lm(y〜x1 + x2 + x3 + x4,data = data2)

reg3< -lm(y〜x1 + x2 + x3 + x4,data = data3)

然后我尝试执行以下操作: stargazer(reg1,reg2,reg3,type ="text",keep.stat ="all",align = TRUE)

Then I try to do: stargazer(reg1,reg2,reg3,type="text",keep.stat = "all",align = TRUE)

该表已生成但放错了位置(第1行,第1-4行是reg1的结果,但是第2行,第5-8行是reg 2的结果,第3行的9-12的结果).

The table is produced but misplaced (line 1, row 1-4 are the result for reg1, but line 2, row 5-8 are the result for reg 2, row 9-12 for reg3).

有人可以建议吗?谢谢

推荐答案

能否详细介绍一下,您希望输出结果如何?当您将相同的模型(变量)用于不同的数据集时,我不会看到放错位置的输出.

Can you go more into detail, what you expect the output to look like? When you use identical models (variables) with different datasets, I don't see misplaced output.

library("plm")
library("stargazer")

data("Produc", package = "plm")

model1 <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
              data = Produc, 
              index = c("state","year"),
              method="pooling")

model2 <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
              data = Produc, 
              index = c("state","year"),
              method="between")

model3 <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
              data = Produc, 
              index = c("state","year"),
              method="within")

stargazer(model1,model2,model3,type="text",keep.stat = "all",align = TRUE)
stargazer(model1,model2,model3,type="latex",keep.stat = "all",align = TRUE, out="output.tex")

请注意, align 选项仅在乳胶输出中有效,并且仅当您已加载软件包 dcolumn 时才有效.带有和不带有 dcolumn 的乳胶:

Notice that the align option only works in latex output and only if you have loaded the package dcolumn. Latex, with and without the dcolumn:

这篇关于R观星功能产生的表未对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆