简体   繁体   English

R:PLM个人和时间固定效应,但没有其他回归因子

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

I want to run a regression including only time and individual fixed effects (ie no other right-hand side variables). 我想进行仅包括时间和单个固定影响(即没有其他右侧变量)的回归。

I try to do this with plm : 我尝试用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. 但是,语法不正确,仅从模型公式中抑制-1也不起作用。

The error message is: Error in uniqval[as.character(effect), , drop = F] : incorrect number of dimensions 错误消息是: 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? plm仅对时间和单个固定效应进行y回归的正确语法是什么?

Thanks! 谢谢!

Seems to me to be not supported by plm . 在我看来,不受plm支持。 Use a lm approach instead: 改用lm方法:

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)

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

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