1

I'm a beginner with R, so bear with me. I've spent a while trying to fix this issue based on earlier answers, but I can't work it out.

I want to run a panel regression using the plm package. However, when I try code of the form reg<-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within') it gives the error

Error in .rowNamesDF<-(x, value = value) : 
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘10’, ‘11’, ‘14’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’ 

I can't figure out why it says I have duplicate row names. I've tried some of the suggestions made by other people, such as checking anyDuplicated(row.names(mydataframe)) - which tells me there are no duplicated row names - or make.names(mydataframe, unique=TRUE - which doesn't fix the problem.

The data looks like this

   ï..region id year  grpmlnr    grppc   cpi

1   RegionA   1 1998  18245.5  12242.8 167.7      
2   RegionA   1 1999  32060.6  21398.0 140.8      
3   RegionA   1 2000  42074.5  27969.5 120.9    

Any suggestions?

Thank you very much in advance, I'm aware it's a dumb question but I really need help.

Maurits

paqmo
  • 3,649
  • 1
  • 11
  • 21
Maurits W.
  • 13
  • 3
  • 1
    You need to provide a reproducible data example otherwise we cannot help. Please use ```dput()``` on your full data frame or at least the ```` head()```` and post the output in your question. – Fnguyen Apr 17 '20 at 14:55

1 Answers1

2

I am not sure the syntax is correct

reg<-plm(y ~ x1, x2, x3, data=mydataframe, index=c('region', 'year'), model='within')

Did you mean:

reg<-plm(y ~ x1 + x2 + x3, data=mydataframe, index=c('region', 'year'), model='within')

?

Also, note that there is no "region" in you data. However, there is "i..region", or possibly "id", if that is in fact a region id.

desval
  • 2,345
  • 2
  • 16
  • 23
  • Hi, I think you're correct - the syntax is wrong, it should have been + instead of commas. It's working now. I can't believe I didn't realise this. Thank you! – Maurits W. Apr 17 '20 at 15:28