我在R中进行面板数据分析存在一个主要问题 . 我正在尝试为我的分析做一个合并的OLS,固定效果和随机效应模型 . 我使用的数据集如下所示(这只是一个例子,我的数据集包含超过2900个数据):

Y      X1    X2    X3     X4     X5     X6     ID    Year
0,03   0     0     0,05   0,01   0,00   -0,03  1     2013
0,02   0     0     0,05   0,01   0,00   -0,03  2     2013
-0,01  1     0     0,01   -0,02  0,01   0,02   3     2014
-0,04  1     0     0,01   -0,02  0,01   0,02   4     2014
0,01   0     1     0,02   0,05   0,06   0,01   5     2015
-0,06  0     1     0,02   0,05   0,06   0,01   6     2015
0,08   0     1     0,02   0,05   0,06   0,01   7     2015

变量 X1X2 是2014年和2015年的虚拟变量 . 变量 X3-6 是宏观经济因素的变化 . 由于我的数据是每年一次,这些宏观经济因素每年只会改变一次 .

每当我尝试通过汇集的OLS模型

ols <-lm(Y ~ X1+X2+X3+X4+X5+X6, data=Panel)
summary(ols)

R说 Coefficients: (3 are not defined because of singularities . 这三个变量是 X4-6 .

而且,我正在尝试固定效果和随机效果模型

fixed <- plm(Y ~ X1+X2+X3+X4+X5+X6, data=Panel, index=c("country", "year"), model="within")
summary(fixed)

random <- plm(Y ~ X1+X2+X3+X4+X5+X6, data=Panel, index=c("country", "year"), model="random")
summary(random)

不幸的是,R要么说

duplicate couples (time-id)
Error in pdim.default(index[[1]], index[[2]] :

要么

Error in plm.fit(formula, data, model, effect, random.method, random.dfcor, :
empty model

请有人帮我解决这个问题 . 我已经在这个问题上苦苦挣扎了一段时间 .

问候,我感谢任何帮助,

RI