问题
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