如何修复 plm 包中的 'duplicate row.names'?
How to fix 'duplicate row.names' in plm package?
我是 R 的初学者,请多多包涵。我花了一段时间尝试根据之前的答案解决这个问题,但我无法解决。
我想 运行 使用 plm 包进行面板回归。但是,当我尝试 reg<-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within')
形式的代码时,它给出了错误
Error in .rowNamesDF<-(x, value = value) :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘10’, ‘11’, ‘14’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’
我不明白为什么它说我有重复的行名。我尝试了其他人提出的一些建议,例如检查 anyDuplicated(row.names(mydataframe))
- 它告诉我没有重复的行名称 - 或 make.names(mydataframe, unique=TRUE
- 不能解决问题。
数据是这样的
ï..region id year grpmlnr grppc cpi
1 RegionA 1 1998 18245.5 12242.8 167.7
2 RegionA 1 1999 32060.6 21398.0 140.8
3 RegionA 1 2000 42074.5 27969.5 120.9
有什么建议吗?
在此先感谢您,我知道这是一个愚蠢的问题,但我确实需要帮助。
莫里茨
我不确定语法是否正确
reg<-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within')
您的意思是:
reg<-plm(y ~ x1 + x2 + x3, data=mydataframe, index=c('region', 'year'), model='within')
?
另请注意,您的数据中没有 "region"。但是,有 "i..region",或者可能有 "id",如果那实际上是一个区域 ID。
我是 R 的初学者,请多多包涵。我花了一段时间尝试根据之前的答案解决这个问题,但我无法解决。
我想 运行 使用 plm 包进行面板回归。但是,当我尝试 reg<-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within')
形式的代码时,它给出了错误
Error in .rowNamesDF<-(x, value = value) :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘10’, ‘11’, ‘14’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’
我不明白为什么它说我有重复的行名。我尝试了其他人提出的一些建议,例如检查 anyDuplicated(row.names(mydataframe))
- 它告诉我没有重复的行名称 - 或 make.names(mydataframe, unique=TRUE
- 不能解决问题。
数据是这样的
ï..region id year grpmlnr grppc cpi
1 RegionA 1 1998 18245.5 12242.8 167.7
2 RegionA 1 1999 32060.6 21398.0 140.8
3 RegionA 1 2000 42074.5 27969.5 120.9
有什么建议吗?
在此先感谢您,我知道这是一个愚蠢的问题,但我确实需要帮助。
莫里茨
我不确定语法是否正确
reg<-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within')
您的意思是:
reg<-plm(y ~ x1 + x2 + x3, data=mydataframe, index=c('region', 'year'), model='within')
?
另请注意,您的数据中没有 "region"。但是,有 "i..region",或者可能有 "id",如果那实际上是一个区域 ID。