简体   繁体   English

如何使用 PLM 运行州级固定效果

[英]How to run State Level Fixed Effects with PLM

I am trying to run a regression with only state level fixed effects, but not time fixed effects.我正在尝试运行仅具有州级固定效应而不是时间固定效应的回归。

I am trying:我在尝试:

lm1 <- plm(lnwage ~ age + age^2 + education, data = cps, index = "state", model = "within")

But I am not having any luck, and I am only finding information online of people using state and time fixed effects at the same time.但我没有任何运气,我只是在网上找到同时使用状态和时间固定效应的人的信息。

To calculate any fixed effects we can add a dummy for the variable concerned, ok?为了计算任何固定效应,我们可以为相关变量添加一个虚拟变量,好吗? Let's consider the example right there in the plm() documentation and do first an ordinary lm() with the state dummy for states fixed effects.让我们考虑plm()文档中的示例,并首先使用状态固定效果的状态虚拟对象执行普通lm()

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

fe.lm <- lm(log(gsp) ~ 0 + log(pcap) + log(pc) + log(emp) + unemp + 
              factor(state), data=Produc)

> summary(fe.lm)$coef
                                Estimate   Std. Error    t value
log(pcap)                   -0.026149654 0.0290015755 -0.9016632
log(pc)                      0.292006925 0.0251196728 11.6246309
log(emp)                     0.768159473 0.0300917394 25.5272539
unemp                       -0.005297741 0.0009887257 -5.3581508
factor(state)ALABAMA         2.201617056 0.1760038727 12.5089126
factor(state)ARIZONA         2.368088138 0.1751884949 13.5173725
factor(state)ARKANSAS        2.263015801 0.1671716685 13.5370773
...

Now we use plm() where we also have to add the dummy, it isn't shown in the output, though.现在我们使用plm() ,我们还必须添加虚拟对象,但是它没有显示在输出中。

library(plm)
fe.plm <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp + factor(state),
              data=Produc, index=c("state","year"), model="within")

> summary(fe.plm)$coef
              Estimate   Std. Error    t-value      Pr(>|t|)
log(pcap) -0.026149654 0.0290015755 -0.9016632  3.675200e-01
log(pc)    0.292006925 0.0251196728 11.6246309  7.075069e-29
log(emp)   0.768159473 0.0300917394 25.5272539 2.021455e-104
unemp     -0.005297741 0.0009887257 -5.3581508  1.113946e-07

Another option is felm() .另一种选择是felm()

library(lfe)
fe.felm <- felm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp | state | 0, 
                data=Produc) 

> summary(fe.felm)$coef
              Estimate   Std. Error    t value      Pr(>|t|)
log(pcap) -0.026149654 0.0290015755 -0.9016632  3.675200e-01
log(pc)    0.292006925 0.0251196728 11.6246309  7.075069e-29
log(emp)   0.768159473 0.0300917394 25.5272539 2.021455e-104
unemp     -0.005297741 0.0009887257 -5.3581508  1.113946e-07

As one can see, everything yields the same values.正如人们所见,一切都会产生相同的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM