使用miEconAids进行回归输出的替代方案(除了“stargazer”)

时间:2018-05-28 15:51:42

标签: r regression stargazer

我正在寻找使用库micEconAids的估算更漂亮的输出。 stargazer似乎不起作用,除非我使用lm或其他回归包“估算”方程式“看似无关的方程式”。包实现的一些方法我可以自己复制,但不能全部复制。

那么除了summary的回归输出之外,还有其他方法可以让我获得更好的输出吗?

下面我贴了一些编码来举例说明问题:

rm(list=ls())

library(micEconAids)

data(Blanciforti86)

priceNames = c( "pFood1", "pFood2", "pFood3", "pFood4" )
shareNames = c( "wFood1", "wFood2", "wFood3", "wFood4" )

laaidsResult1 = aidsEst( priceNames, shareNames, "xFood", data = Blanciforti86,
                         priceIndex = "S"  )

laaidsResult2 = aidsEst( priceNames, shareNames, "xFood", data = Blanciforti86,
                        priceIndex = "P"  )

laaidsResult3 = aidsEst( priceNames, shareNames, "xFood", data = Blanciforti86,
                        priceIndex = "SL"  )

summary(laaidsResult1)
summary(laaidsResult2)
summary(laaidsResult3)

#Stargazer does not work with `micEconAids`:

stargazer::stargazer(laaidsResult1, laaidsResult2, laaidsResult3)

#What are the alternatives for showing a prettier output?

#######################################################################################################################

#In the previous examples, an AIDS model was regressed.
#Below there is an example of how the models could/should look like -- in a three equation setup --
#using `lm` function, which works with `stargazer`.


reg1 = lm(Blanciforti86$wFood1 ~ Blanciforti86$pFood1)
reg2 = lm(Blanciforti86$wFood2 ~ Blanciforti86$pFood2)
reg3 = lm(Blanciforti86$wFood3 ~ Blanciforti86$pFood3)

stargazer::stargazer(reg1,reg2,reg3, type="text")

1 个答案:

答案 0 :(得分:1)

aidsEst的输出在列表结构中有大量信息。  如果您要检查的是特定的输出集,则可以将其拉出并使用broom::tidy()以更好的格式查看。

例如,aidsEst()包含$coef个对象,而该对象又有$stat个数据框。
使用tidy()

tidy(laaidsResult1$coef$stat)

   .rownames     Estimate  Std..Error    t.value     Pr...t..
1    alpha 1 -0.247298293 0.070079963 -3.5288017 6.798727e-04
2    alpha 2  0.109249097 0.057874966  1.8876745 6.252270e-02
3    alpha 3  0.268238436 0.034413442  7.7945832 1.560840e-11
4    alpha 4  0.869810761 0.090578360  9.6028539 3.635728e-15
5     beta 1  0.323989176 0.041041424  7.8941991 9.873279e-12
6     beta 2  0.055863164 0.033599356  1.6626261 1.001146e-01
7     beta 3 -0.078626097 0.020025657 -3.9262681 1.760820e-04
8     beta 4 -0.301226244 0.052987085 -5.6848993 1.848756e-07
9  gamma 1 1  0.104150200 0.020804442  5.0061521 3.018569e-06
10 gamma 1 2 -0.139880152 0.015303438 -9.1404395 3.094504e-14

使用str(laaidsResult1)aidsEst输出中查找您正在寻找的特定内容。