I'm trying to run a fixed effects regression using the plm package. The regression code is as following:
fixed = plm(hp~crime,index=c('year','country'),data=data,model='within')
which returns the following error code:
error in pdim.default(index[[1]], index[[2]]) : duplicate couples (id-time)
I have searched the web, including stackoverflow. What I understand is that plm can only run with two ID's, so if you have several ID's, you'll how to 'cheat' plm by merging these before indexing. However, my data only consists of the columns: country, year, hp and crime, so I do not understand how this is possible.
Essentially what I'm asking, am I doing something wrong? Do I still need to merge these two IDs or is the fault within my duplicates of my rows, if that is the case is it possibly to find the duplicates by coding? (I have manually tried to look through my panel data to find duplicates of IDs, i.e. several values of house prices for year 1 for country 1.
If I run
any(table(data$country,data$year)!=1)
I get TRUE. As I can understand this shows that there aren't any duplicates of country+year combination.