R: plm individual and time fixed effects but no other regressors

不羁岁月 提交于 2019-12-10 18:53:39

问题


I want to run a regression including only time and individual fixed effects (i.e. no other right-hand side variables).

I try to do this with plm:

plm(y ~ -1,data=data, effect="twoways", model="within")

However, the syntax is not correct, nor does it work to just suppress the -1 from the model formula.

The error message is: Error in uniqval[as.character(effect), , drop = F] : incorrect number of dimensions

What is the correct syntax with plm for a regression of y on only time and individual fixed effects?

Thanks!


回答1:


Seems to me to be not supported by plm. Use a lm approach instead:

library(plm)
data(Grunfeld)

# not possible with plm
mod <- plm(inv ~ -1, data=Grunfeld, model="within", effect = "twoways")

# use lm instead
mod2 <- lm(inv ~ -1 + factor(firm) + factor(year), data=Grunfeld)


来源:https://stackoverflow.com/questions/34369109/r-plm-individual-and-time-fixed-effects-but-no-other-regressors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!