The data to be used is the following panel data (unbalanced_pdf).pdata.frame() is converting to the format for plm.(Leftmost row: Company id-year)
//// name price PBR
1 - 2009 Company a18900.8
1 - 2010 Company a18900.9
1 - 2011 Company a 1912 1.0
2 - 2011 Company b 1988 0.7
2-2012 Company b 28850.9
2-2013 Company b29830.8
Based on this data, the following commands are issued for regression analysis and an error is displayed:
commands executed:
fixedeffect_unbalanced_model<-plm (PBR~price+…, data=unbalanced_pdf, method="within", effect="individual")
error messages:
`.rowNamesDF<-`(x,value=value): Duplicate 'row.names' are not allowed
This data is incomplete panel data that some objects do not have data for the entire time period, but the same analysis with the complete panel data did not display the above error message.
I would appreciate it if you could let me know if there is any reason you can think of.
Since it is difficult to publish the data code that reproduces the problem, and we cannot reproduce the problem, it is only the first thing to try in the whole programming problem, but please try the following first.
Also, since the code has not been released yet, it is a guess, but have you done the following?
If you have any new information, please attach it to the comments in this answer.
As shown in the error, R cannot have duplicate ronames.
(Rownname is like an ID that is dumped by column)
If you could share the minimal reprex
, you would get a more detailed answer, but
I guess
and so on?
Originally, I think we should consider cleaning the data based on the concept of tidy data
, but
There is an auxiliary function make.names()
that re-shakes ronames at such times, so
Why don't you try this once?
rounames(unbalanced_pdf2)<-make.names(unbalanced_pdf[,1], unique=TRUE)
Reference (English)
https://stackoverflow.com/questions/31707654/r-set-duplicate-row-names-to-a-numeric-data-frame
In addition, roname is rarely used for modern R processing using tidyverse
.
(Not recommended) I felt that encountering errors around the roname itself was a reference to some old documentation.
If you don't need to divert legacy code, try using tidyverse which is easy to access and highly efficient.
© 2024 OneMinuteCode. All rights reserved.