0

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!

jo.magi
  • 29
  • 1
  • 7
  • 2
    Have you checked to make sure that there are no duplicates? Also, did you at any point use the `plm.data` function to make sure that your data is in `plm.data` format? – Abdou Aug 10 '16 at 09:29
  • I did check and the duplicates that come up are not duplicates of entire rows, but vary because they have a different sanction type. I still get the error even when i do the plm.data – jo.magi Aug 10 '16 at 09:54
  • 1
    That's not what the `plm` function is complaining about. Your indexes are `country` and `sanctions_period`, but you can clearly see that all three rows you've shown here are duplicates of each other. The combination of `country` and `sanctions_period` should be unique for every row. – Abdou Aug 10 '16 at 10:06
  • That makes sense. Any suggestions what i could do to see the effects over time and across countries? The dataset is obviously bigger than stated above. – jo.magi Aug 10 '16 at 10:18
  • Why not have the `sanctions_period` column be a year (for example `1995`) instead of a range `(1995-2002)`. You can then use a combination of `Year` and `Country` as your `id`. – Abdou Aug 10 '16 at 10:21
  • Wouldn't i still have the same problem as for most sanctions they are imposed in one year but are different types? – jo.magi Aug 10 '16 at 10:25
  • I feel like this a `Pooled Cross Section` rather than your typical `panel data` series. Ideally in a panel data series, you expect each country to have one sanction in one year. But what you have is that for a given year, a country may have more than one sanction. Look into `Pooled Cross Section` models. – Abdou Aug 10 '16 at 11:07

1 Answers1

0

This as been discussed in two different posts:

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.

Matifou
  • 7,968
  • 3
  • 47
  • 52