I have a panel data set with individual (dyad_id), which is an integer, and time (year_month) which is a Date variable. I try running the following code:
df.fe <- plm(deaths_civilians ~ deaths_a_lag + deaths_b_lag,
data = rebel,
index = c("dyad_id", "year_month"),
model = "within",
effect = "individual")
but I keep getting the following error message:
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)
3: In is.pbalanced.default(index[[1]], index[[2]]) :
duplicate couples (id-time)
All previous answers to this question say that it is because I have more than one observation with the same ID for the same time period, but I have checked and this is not the case. I have tried transforming both the ID and year_month into different types of variables (factors, integers etc) but nothing works.
I cannot really provide any reproducible data that would help diagnose the problem because my final dataset is the result of merging about 6 separate datasets, and about 300 lines of code. However, would anybody be able to suggest a potential reason for this problem and any remedies?