【问题标题】:Erros in pmg regressionpmg 回归中的错误
【发布时间】:2018-05-11 15:09:24
【问题描述】:

我有以下类型的面板数据集。

> head(fund_panel)
      month  months           fund_name                     return ex_mkt_ret id
    1     1 01-1998 27four Shari'ah Active Eq. Prescient A1     NA   -0.21268  1
    2     2 02-1998 27four Shari'ah Active Eq. Prescient A1     NA    0.06325  1
    3     3 03-1998 27four Shari'ah Active Eq. Prescient A1     NA   -0.04369  1
    4     4 04-1998 27four Shari'ah Active Eq. Prescient A1     NA   -0.02485  1
    5     5 05-1998 27four Shari'ah Active Eq. Prescient A1     NA   -0.11840  1
    6     6 06-1998 27four Shari'ah Active Eq. Prescient A1     NA   -0.34746  1

R 使用包 plm 及其函数 pmg 显示以下 Fama-Macbeth 回归错误:

> fpmg <- pmg(return ~ ex_mkt_ret, fund_panel, index=c("month", "id")) ##Fama-MacBeth
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)

我通过互联网来解决这个问题,但我无法弄清楚。请,您的建议。

【问题讨论】:

    标签: r panel-data plm


    【解决方案1】:

    给出的错误信息应该很明显: duplicate couples (id-time)

    这意味着您的数据集中有行为同一个人指定了(至少)两次相同的时间段(例如,在 2016、2017、2018、2018 年对个人 1 的观察)。

    但是,在查看您的数据集以及如何为估计命令指定索引时(请参阅 ?pmg),您似乎希望将列 id 作为单独的索引,将 month 作为时间指数。参数indexto pmg 采用第一个位置的单个索引和第二个位置的时间索引。因此,翻转idtime 应该可以工作:

    fpmg &lt;- pmg(return ~ ex_mkt_ret, fund_panel, index=c("id", "month"))

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-25
      • 1970-01-01
      • 2023-03-30
      • 2017-05-17
      • 2020-10-29
      • 1970-01-01
      • 1970-01-01
      • 2018-05-01
      相关资源
      最近更新 更多