同事们!我有面板数据:
Company year Beta NI Sales Export Hedge FL QR AT Foreign
1 1 2010 -2.2052800 293000 1881000 78.6816 0 23.5158 1.289 0.6554 3000
2 1 2011 -2.2536069 316000 2647000 81.4885 0 21.7945 1.1787 0.8282 22000
3 1 2012 0.3258693 363000 2987000 82.4908 0 24.5782 1.2428 0.813 -11000
4 1 2013 0.4006030 549000 4546000 79.4325 0 31.4168 0.6038 0.7905 71000
5 1 2014 -0.4508811 348000 5376000 79.2411 0 37.1451 0.6563 0.661 -64000
6 1 2015 0.1494696 355000 5038000 77.1735 0 33.3852 0.9798 0.5483 37000
但是当我尝试使用plm软件包进行回归时,R会显示错误:
panel <- read.csv("Panel.csv", header=T, sep=";")
p=plm(data=panel,Beta~NI, model="within",index=c("id","year"))
Error in pdim.default(index[[1]], index[[2]]) :
duplicate couples (id-time)
In addition: Warning messages:
1: In pdata.frame(data, index) :
duplicate couples (id-time) in resulting pdata.frame
to find out which, use e.g. table(index(your_pdataframe), useNA = "ifany")
2: In is.pbalanced.default(index[[1]], index[[2]]) :
duplicate couples (id-time)
3: In is.pbalanced.default(index[[1]], index[[2]]) :
duplicate couples (id-time)
我在互联网上搜索了这个错误,发现它与公司ID和年份有关。但我没有找到避免这个问题的方法。此外,当我执行na.omit(panel)时,R不会显示错误,但保留NA数据和公司数据对于数据分析是重要的。请告诉我如何解决这个问题。谢谢。
any(table(Produc$state, Produc$year) > 1)
。 - jay.sf