Problems with plm, duplicate time id's error

拈花ヽ惹草 提交于 2021-02-05 10:55:17

问题


I am running a fixed effects regression and am getting the following error:

fixed_effects <- plm(GNI ~ lag(GNI) + imposition + ExpImp + democ, 
data = sanctions_data6, index = c("country", "sanctions_period"), model =
"within", effect = "twoways")

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

I am aware that it means that i have duplicate time periods for the same observations. However the whole observations are not duplicates of each other as they represent different types of sanctions imposed.

           country        sanctions_period     sanction_type
             (chr)            (chr)            (int)
1          Afghanistan        1995-2002          4
2          Afghanistan        1995-2002          7
3          Afghanistan        1995-2002          NA

How can i get around this problem and run a regression in order to see the results? Thanks!


回答1:


This as been discussed in two different posts:

  • https://stats.stackexchange.com/questions/85909/why-does-a-fixed-effect-ols-need-unique-time-elements/390667#390667

  • Fixed Effects plm package R - multiple observations per year/id

Basically, plm want you to have unique time values for each group. You can trick plm by simply creating unique time values by creating a sanctions_period -sanction_type variable.



来源:https://stackoverflow.com/questions/38869101/problems-with-plm-duplicate-time-ids-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!