0

I am working with panel data in R, and I want to run a two way panel fixed effects model on my data set so I used plm:

plm1 <- plm(rprofit_acre~dd89+prcp_0410, data=data, effect="twoways", model="within")

and I am getting the error message

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

I used the suggestion in the error message to see if there are any duplicates of state+year combination with the line

any(table(data$state,data$year)!=1)

and the result was TRUE, meaning that there aren't any duplicates of state+year combination.

Helix123
  • 3,502
  • 2
  • 16
  • 36

1 Answers1

0

The suggestion in the error message (which you do not reprint fully) is actually table(index(your_pdataframe), useNA = "ifany"). If it prints something differently on your end, use a current version of the package.

You modified that and test for any combinations which appear less or more than once (by != 1). If that yields TRUE, you cannot infer there are no duplicated couples, rather the opposite is true (there can be less and more than one).

So, you can use the suggestion from the error message to identify the duplicated combinations.

Helix123
  • 3,502
  • 2
  • 16
  • 36