2

I'm attempting to run a random effects regression on panel data, but i receive the error message:

Error in .rowNamesDF<-(x, value = value) : duplicate 'row.names' are not allowed In addition: Warning message: non-unique values when setting 'row.names': ‘3-2016’, ‘3-2017’, ‘3-2018’, ‘3-2019’, ‘4-2015’, ‘4-2016’

This has happened since I've used

df$ID <- as.numeric(as.factor(df$Team))

to generate IDs for each NBA team. Previously I was using a very ramshackle approach where I exported the dataset to excel using xlsx, manually entered the IDs in and then imported the new data set. But now, even when I try the old method i receive the same error code.

This is the command I use to put the data in panel data format:

pdata <- pdata.frame(df, index=c("ID","Year"))

When I use table(index(pdata), useNA = "ifany")

all columns from 2015-2019 are all 1s


ID   2015 2016 2017 2018 2019
  1     1    1    1    1    1
  2     1    1    1    1    1
  3     1    1    1    1    1
  4     1    1    1    1    1
  5     1    1    1    1    1
  .

  .

  .

I've tried to be as descriptive as possible, I'm sorry if this is formatted strange or lacks vital information, I'm not a programmer by schooling, and my major only uses Stata for regression analysis.

RAFrancais
  • 57
  • 4
  • What is the specific line of code that gives that error? What do you get when you use `rownames` on your data frame? Are they actually non-unique? – divibisan Apr 30 '19 at 21:59
  • ```random <- plm(Y ~ x1 + x2 + x3 +x4+ x5, +x6, data=pdata, model= "random")``` Yes they are unique, there only exists one row '3-2016' and '3-2017' etc. – RAFrancais May 01 '19 at 00:04
  • 1
    Take a look at [How to make a great R reproducible Example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It's really hard to troubleshoot your problem when you don't show your code or your data. If that line you mention is what gives the error, you need to show that code and `pdata`, since there's likely some issue with your data. – divibisan May 01 '19 at 15:17
  • Ideally, you could make a [mcve] of your problem with a minimal dataset that reproduces the problem which you could share with `dput`. If that's impossible, then I'd like to see `head(pdata)` and `str(pdata)`. Also, what package are `pdata.frame` and `plm` from? Please [edit] your question to add this info, since it's really hard to read code or data in comments. – divibisan May 01 '19 at 15:23

0 Answers0