pmg 回归错误
Erros in pmg regression
我有以下类型的面板数据集。
> 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)
我通过互联网来解决这个问题,但我想不通。请您提出建议。
给出的错误信息应该很明显:
duplicate couples (id-time)
这意味着您的数据集中有行为同一个人指定了(至少)两次相同的时间段(例如,对个人 1 在 2016 年、2017 年、2018 年、2018 年的观察)。
但是,在查看您的数据集以及您如何为估计命令指定索引时(请参阅 ?pmg
),您似乎希望将列 id
作为单独的索引month
作为时间索引。参数 index
到 pmg
在第一个位置采用个人索引,在第二个位置采用时间索引。因此,翻转 id
和 time
应该有效:
fpmg <- pmg(return ~ ex_mkt_ret, fund_panel, index=c("id", "month"))
我有以下类型的面板数据集。
> 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
:
> 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)
我通过互联网来解决这个问题,但我想不通。请您提出建议。
给出的错误信息应该很明显:
duplicate couples (id-time)
这意味着您的数据集中有行为同一个人指定了(至少)两次相同的时间段(例如,对个人 1 在 2016 年、2017 年、2018 年、2018 年的观察)。
但是,在查看您的数据集以及您如何为估计命令指定索引时(请参阅 ?pmg
),您似乎希望将列 id
作为单独的索引month
作为时间索引。参数 index
到 pmg
在第一个位置采用个人索引,在第二个位置采用时间索引。因此,翻转 id
和 time
应该有效:
fpmg <- pmg(return ~ ex_mkt_ret, fund_panel, index=c("id", "month"))