r - 面板数据模型: Duplicate couples error when there are no duplicate couples

标签 r panel-data plm

我有一个面板数据集,其中包含个体(dyad_id)(整数)和时间(year_month)(日期变量)。我尝试运行以下代码:

df.fe <- plm(deaths_civilians ~ deaths_a_lag + deaths_b_lag, 
                         data = rebel, 
                         index = c("dyad_id", "year_month"), 
                         model = "within", 
                         effect = "individual")

但我不断收到以下错误消息:

Error in pdim.default(index[[1]], index[[2]]) : 
  duplicate couples (id-time)
In addition: Warning messages:
1: In pdata.frame(data, index) :
  duplicate couples (id-time) in resulting pdata.frame
 to find out which, use e.g. table(index(your_pdataframe), useNA = "ifany")
2: In is.pbalanced.default(index[[1]], index[[2]]) :
  duplicate couples (id-time)

3: In is.pbalanced.default(index[[1]], index[[2]]) :
  duplicate couples (id-time)

这个问题之前的所有答案都说这是因为我在同一时间段内有多个具有相同 ID 的观察,但我检查过,情况并非如此。我尝试将 ID 和year_month 转换为不同类型的变量(因子、整数等),但没有任何效果。

我确实无法提供任何可重现的数据来帮助诊断问题,因为我的最终数据集是合并大约 6 个独立数据集和大约 300 行代码的结果。但是,有人能够提出这个问题的潜在原因和补救措施吗?

最佳答案

我也有同样的错误。确保在运行 plm 回归时输入面板数据的名称。如果您输入您的 ould 数据集的名称(未设置为面板的名称),则会出现此错误。

关于r - 面板数据模型: Duplicate couples error when there are no duplicate couples,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45677576/

相关文章:

r - 将点添加到ggplot2中的Choropleth映射

r - 将 R ggridges (R-joyplot) 用于条形图

r - 如何在 R 中获取面板数据固定效应回归的 corr(u_i, Xb)

r - R中plm包中具有三个固定效应的模型

四舍五入问题

r - 在每个组的嵌套数据中通过 across 应用简单函数

R从组的开始日期和结束日期创建时间序列的最佳方法

r - 为面板数据中的每个组变量提取拟合值

r - 尝试运行固定效应逻辑回归时出错

r - 如何从 plm FE 回归中获得 between 和 overall R2?