Error in plm function: 'names' attribute [343] must be the same length as the vector [0]

孤街醉人 提交于 2021-02-08 12:13:44

问题


I am running a panel regression using 'plm' function using the following code:

 test_reg=plm(y~x1+x2+x3+x4*x7+x5*x7+x6*x7+x8+x9+x10+x11,DATA, index = c("year","id"),model ="within")

 summary(test_reg)

Then I get the following error:

 Error in names(y) <- namesy : 
   'names' attribute [343] must be the same length as the vector [0]

However, when I switch the y variable and x10 variable and run the same 'plm' function again, I do not get such an error and it works well like:

 test_reg=plm(x10~x1+x2+x3+x4*x7+x5*x7+x6*x7+x8+x9+y+x11,DATA, index = c("year","id"),model ="within")

 summary(test_reg)

The data looks like this:

Date        ID  x1  x2  x3  x4  x5  x6  x7  x8       x9         x10            y                x11
01/01/2017  1   1   0   0   1   0   0   1   6.5 291.7261837 0.003809784 -0.002609372    0.06258402
01/01/2017  2   0   0   0   1   0   0   1   6.5 291.7261837 0.003809784 -0.002609372    0.06258402
01/01/2017  3   1   0   0   0   1   0   0   7.8 291.7261837 0.005244375 -0.002609372    0.06258402
01/03/2017  4   1   0   0   0   0   0   0   7.8 291.7261837 0.006340987 -0.002609372    0.06258402
01/04/2017  5   0   0   0   1   0   0   1   6.5 291.7261837 0.003923172 0.105154594 0.062638589
01/04/2017  6   0   0   0   1   0   0   1   6.5 291.7261837 0.003923172 0.105154594 0.062638589
01/04/2017  7   0   1   0   1   0   0   0   6.5 291.7261837 0.010499933 0.105154594 0.062638589
01/04/2017  8   0   0   0   0   1   0   0   7.3 291.7261837 0.004619899 0.105154594 0.062638589
01/05/2017  9   0   0   0   0   1   0   0   6.1 291.7261837 0.0069687   -0.16129731 0.062806962
01/05/2017  10  0   0   0   1   0   0   0   7.7 291.7261837 0.006392705 -0.16129731 0.062806962
01/05/2017  11  0   0   0   0   1   0   0   7.3 291.7261837 0.003693392 -0.16129731 0.062806962
01/06/2017  12  1   0   0   1   0   0   1   6.5 291.7261837 0.003951792 -0.070975051    0.06281527
01/06/2017  13  0   1   0   1   0   0   0   6.3 291.7261837 0.006345245 -0.070975051    0.06281527
01/06/2017  14  0   1   0   1   0   0   0   7.8 291.7261837 0.006057317 -0.070975051    0.06281527
01/06/2017  15  0   0   0   0   0   0   0   3.2 291.7261837 0.017651031 -0.070975051    0.06281527
01/07/2017  16  0   1   0   1   0   0   1   6.5 291.7261837 0.003230524 -0.003762958    0.062785401
01/07/2017  17  0   0   0   1   0   0   1   6.5 291.7261837 0.003230524 -0.003762958    0.062785401
01/08/2017  18  0   0   0   1   0   0   1   6.5 291.7261837 0.003575814 -0.003762958    0.062785401
01/09/2017  19  0   0   0   1   0   0   1   6.5 291.7261837 0.003751772 -0.003762958    0.062785401
01/09/2017  20  0   0   0   1   0   0   1   6.5 291.7261837 0.003751772 -0.003762958    0.062785401
01/10/2017  21  0   0   0   1   0   0   1   6.5 291.7261837 0.003236778 0.010738193 0.062756344
01/10/2017  22  1   0   0   0   0   0   0   6.3 291.7261837 0.005293044 0.010738193 0.062756344
01/11/2017  23  0   0   0   1   0   0   1   6.5 291.7261837 0.002724046 -0.159969555    0.062920422
01/11/2017  24  0   0   0   1   0   0   1   6.5 291.7261837 0.002724046 -0.159969555    0.062920422
01/11/2017  25  0   0   0   1   0   0   0   5.8 291.7261837 0.004853874 -0.159969555    0.062920422
01/11/2017  26  0   0   0   0   1   0   0   6.3 291.7261837 0.006511518 -0.159969555    0.062920422
01/12/2017  27  0   1   0   1   0   0   1   6.5 291.7261837 0.002594988 0.046721689 0.062906992
01/12/2017  28  0   1   0   1   0   0   0   7.3 291.7261837 0.003968837 0.046721689 0.062906992
01/13/2017  29  0   0   0   1   0   0   1   6.5 291.7261837 0.002472768 0.028186561 0.062883091
01/13/2017  30  0   0   0   1   0   0   0   6.1 291.7261837 0.007287802 0.028186561 0.062883091
01/13/2017  31  1   0   0   0   0   0   0   6.3 291.7261837 0.004395253 0.028186561 0.062883091
01/13/2017  32  1   0   0   0   0   0   0   6.3 291.7261837 0.004395253 0.028186561 0.062883091
01/13/2017  33  0   0   0   1   0   0   0   7.8 291.7261837 0.00674419  0.028186561 0.062883091
01/14/2017  34  0   0   0   1   0   0   1   6.5 291.7261837 0.002287315 0.003937596 0.062853342
01/14/2017  35  0   0   0   1   0   0   1   6.5 291.7261837 0.002287315 0.003937596 0.062853342
01/14/2017  36  1   0   0   0   0   0   0   3.2 291.7261837 0.016146024 0.003937596 0.062853342
01/15/2017  37  0   1   0   1   0   0   1   6.5 291.7261837 0.002474269 0.003937596 0.062853342
01/15/2017  38  0   0   1   1   0   0   0   7.3 291.7261837 0.005575788 0.003937596 0.062853342
01/16/2017  39  0   0   0   1   0   0   1   6.5 291.7261837 0.002719306 0.003937596 0.062853342
01/16/2017  40  0   0   0   0   1   0   0   7.3 291.7261837 0.008550097 0.003937596 0.062853342
01/16/2017  41  0   1   0   1   0   0   0   5.7 291.7261837 0.006760413 0.003937596 0.062853342
01/17/2017  42  0   1   0   1   0   0   1   6.5 291.7261837 0.002718686 0.078898669 0.062870506
01/17/2017  43  0   1   0   1   0   0   0   5.7 291.7261837 0.006016846 0.078898669 0.062870506
01/17/2017  44  0   0   0   1   0   0   0   7.3 291.7261837 0.005614425 0.078898669 0.062870506
01/17/2017  45  0   0   0   1   0   0   0   5.7 291.7261837 0.004262791 0.078898669 0.062870506
01/18/2017  46  0   0   0   1   0   0   1   6.5 291.7261837 0.002472575 -0.028161673    0.062846684
01/18/2017  47  0   1   0   1   0   0   1   6.5 291.7261837 0.002472575 -0.028161673    0.062846684
01/18/2017  48  0   1   0   1   0   0   1   6.5 291.7261837 0.002472575 -0.028161673    0.062846684
01/20/2017  49  0   0   0   1   0   0   1   6.5 291.7261837 0.002401105 -0.006736635    0.062794741
01/20/2017  50  0   0   0   1   0   0   1   6.5 291.7261837 0.002401105 -0.006736635    0.062794741
01/20/2017  51  0   1   0   1   0   0   1   6.5 291.7261837 0.002401105 -0.006736635    0.062794741
01/20/2017  52  0   0   0   1   0   0   1   6.5 291.7261837 0.002401105 -0.006736635    0.062794741
01/21/2017  53  0   1   0   1   0   0   1   6.5 291.7261837 0.002553359 0.024072255 0.062769421
01/21/2017  54  0   0   0   1   0   0   0   7.3 291.7261837 0.005116216 0.024072255 0.062769421
01/21/2017  55  0   1   0   1   0   0   0   7.8 291.7261837 0.006584331 0.024072255 0.062769421
01/22/2017  56  0   1   0   1   0   0   1   6.5 291.7261837 0.002955839 0.024072255 0.062769421
01/23/2017  57  0   0   0   1   0   0   0   6.5 291.7261837 0.015364925 0.024072255 0.062769421
01/23/2017  58  0   0   0   0   0   1   0   5.2 291.7261837 0.004840524 0.024072255 0.062769421
01/23/2017  59  0   0   1   1   0   0   0   7.8 291.7261837 0.007814092 0.024072255 0.062769421
01/24/2017  60  0   1   0   1   0   0   1   6.5 291.7261837 0.003216472 -0.012183546    0.062740895
01/24/2017  61  0   0   0   1   0   0   1   6.5 291.7261837 0.003216472 -0.012183546    0.062740895
01/25/2017  62  0   0   0   1   0   0   1   6.5 291.7261837 0.003073038 -0.018516248    0.062713872
01/25/2017  63  0   0   0   1   0   0   1   6.5 291.7261837 0.003073038 -0.018516248    0.062713872
01/25/2017  64  0   1   0   1   0   0   1   6.5 291.7261837 0.003073038 -0.018516248    0.062713872
01/25/2017  65  0   0   0   1   0   0   1   6.5 291.7261837 0.003073038 -0.018516248    0.062713872
01/25/2017  66  0   0   0   1   0   0   1   6.5 291.7261837 0.003073038 -0.018516248    0.062713872
01/25/2017  67  0   1   0   1   0   0   0   4.3 291.7261837 0.006130505 -0.018516248    0.062713872
01/25/2017  68  0   1   0   1   0   0   0   7.3 291.7261837 0.005463339 -0.018516248    0.062713872
01/25/2017  69  0   0   0   0   1   0   0   7.2 291.7261837 0.005378501 -0.018516248    0.062713872
01/25/2017  70  0   1   0   0   1   0   0   7.8 291.7261837 0.006395996 -0.018516248    0.062713872
01/26/2017  71  0   0   0   1   0   0   1   6.5 291.7261837 0.003005659 0.025344647 0.06268914
01/26/2017  72  0   0   0   1   0   0   1   6.5 291.7261837 0.003005659 0.025344647 0.06268914
01/26/2017  73  0   1   0   1   0   0   0   8.3 291.7261837 0.005294032 0.025344647 0.06268914
01/27/2017  74  0   0   0   1   0   0   1   6.5 291.7261837 0.003009194 0.004480483 0.062659769
01/27/2017  75  0   1   0   1   0   0   1   6.5 291.7261837 0.003009194 0.004480483 0.062659769
01/27/2017  76  1   0   0   1   0   0   0   5.7 291.7261837 0.005807761 0.004480483 0.062659769
01/27/2017  77  0   0   0   0   1   0   0   6.1 291.7261837 0.006862177 0.004480483 0.062659769
02/01/2017  78  0   0   1   1   0   0   0   6.5 225.4411382 0.011340764 0.017358588 0.062584951
02/02/2017  79  1   0   0   1   0   0   1   6.5 225.4411382 0.002466055 0.026781623 0.062560967
02/02/2017  80  0   1   0   0   1   0   0   5.7 225.4411382 0.007882781 0.026781623 0.062560967
02/03/2017  81  0   0   0   1   0   0   1   6.5 225.4411382 0.002405885 0.011539691 0.062532642
02/03/2017  82  1   0   0   0   1   0   0   7.2 225.4411382 0.005045113 0.011539691 0.062532642
02/03/2017  83  1   0   0   1   0   0   0   7.8 225.4411382 0.003676336 0.011539691 0.062532642
02/04/2017  84  0   0   0   1   0   0   1   6.5 225.4411382 0.002654186 0.010467481 0.06250418
02/04/2017  85  0   1   0   1   0   0   0   6.1 225.4411382 0.006578092 0.010467481 0.06250418
02/04/2017  86  0   1   0   1   0   0   0   7.8 225.4411382 0.003632123 0.010467481 0.06250418
02/05/2017  87  0   0   0   1   0   0   0   7.3 225.4411382 0.005081024 0.010467481 0.06250418
02/06/2017  88  0   0   0   0   0   0   1   6.5 225.4411382 0.003728276 0.010467481 0.06250418
02/06/2017  89  0   0   0   1   0   0   1   6.5 225.4411382 0.003728276 0.010467481 0.06250418
02/06/2017  90  0   1   0   1   0   0   1   6.5 225.4411382 0.003728276 0.010467481 0.06250418
02/06/2017  91  0   0   0   1   0   0   0   6.1 225.4411382 0.007556925 0.010467481 0.06250418
02/07/2017  92  1   0   0   0   1   0   0   6.1 225.4411382 0.00669479  0.025720122 0.062479891
02/07/2017  93  1   0   0   0   0   0   0   6.3 225.4411382 0.005333849 0.025720122 0.062479891
02/07/2017  94  0   0   0   1   0   0   0   5.7 225.4411382 0.005515754 0.025720122 0.062479891
02/07/2017  95  0   1   0   1   0   0   0   7.7 225.4411382 0.00544694  0.025720122 0.062479891
02/07/2017  96  1   0   0   0   0   0   0   7.3 225.4411382 0.004661699 0.025720122 0.062479891
02/07/2017  97  0   0   0   0   0   0   0   7.8 225.4411382 0.003527638 0.025720122 0.062479891
02/08/2017  98  0   1   0   1   0   0   1   6.5 225.4411382 0.00317671  0.009337221 0.06245134
02/08/2017  99  0   1   0   1   0   0   1   6.5 225.4411382 0.00317671  0.009337221 0.06245134
02/08/2017  100 0   0   0   1   0   0   0   6.1 225.4411382 0.00590983  0.009337221 0.06245134
02/08/2017  101 0   1   0   1   0   0   0   7.8 225.4411382 0.002880073 0.009337221 0.06245134
02/08/2017  102 0   0   0   1   0   0   0   7.8 225.4411382 0.002880073 0.009337221 0.06245134
02/09/2017  103 0   1   0   1   0   0   1   6.5 225.4411382 0.003220582 -0.073642932    0.062462725
02/09/2017  104 0   1   0   1   0   0   0   7.7 225.4411382 0.00457101  -0.073642932    0.062462725
02/09/2017  105 0   1   0   1   0   0   0   7.3 225.4411382 0.006184487 -0.073642932    0.062462725
02/09/2017  106 1   0   0   0   1   0   0   6.7 225.4411382 0.007553324 -0.073642932    0.062462725
02/10/2017  107 1   0   0   1   0   0   1   6.5 225.4411382 0.003220913 0.02054262  0.062436737
02/10/2017  108 0   1   0   0   1   0   0   7.3 225.4411382 0.006192293 0.02054262  0.062436737
02/10/2017  109 1   0   0   0   1   0   0   6.3 225.4411382 0.005740194 0.02054262  0.062436737
02/11/2017  110 0   0   0   0   1   0   0   5.8 225.4411382 0.005764743 -0.005847667    0.062407891
02/12/2017  111 1   0   0   0   0   1   0   7.8 225.4411382 0.002921387 -0.005847667    0.062407891
02/13/2017  112 0   0   1   1   0   0   0   6.1 225.4411382 0.007966682 -0.005847667    0.062407891
02/14/2017  113 1   0   0   1   0   0   1   6.5 225.4411382 0.00347653  0.014188136 0.062380333
02/14/2017  114 0   0   0   1   0   0   1   6.5 225.4411382 0.00347653  0.014188136 0.062380333
02/14/2017  115 0   0   0   1   0   0   1   6.5 225.4411382 0.00347653  0.014188136 0.062380333
02/14/2017  116 0   0   0   0   1   0   0   6.1 225.4411382 0.007354973 0.014188136 0.062380333
02/14/2017  117 0   1   0   1   0   0   0   4.3 225.4411382 0.005106887 0.014188136 0.062380333
02/14/2017  118 0   0   0   0   0   1   0   6.5 225.4411382 0.00458087  0.014188136 0.062380333
02/14/2017  119 0   0   0   0   1   0   0   4.5 225.4411382 0.004021296 0.014188136 0.062380333
02/15/2017  120 0   1   0   0   1   0   1   6.5 225.4411382 0.003084593 -0.000418977    0.062351313
02/15/2017  121 0   0   0   1   0   0   0   6.1 225.4411382 0.006590897 -0.000418977    0.062351313
02/15/2017  122 1   0   0   1   0   0   0   7.7 225.4411382 0.004885155 -0.000418977    0.062351313
02/15/2017  123 0   0   0   1   0   0   0   5.2 225.4411382 0.0040034   -0.000418977    0.062351313
02/15/2017  124 1   0   0   0   0   1   0   5.3 225.4411382 0.004399054 -0.000418977    0.062351313
02/16/2017  125 0   0   0   0   1   0   0   7.3 225.4411382 0.004595518 0.022443541 0.062326088
02/17/2017  126 1   0   0   1   0   0   1   6.5 225.4411382 0.002695262 0.022801391 0.062301021
02/17/2017  127 0   0   0   1   0   0   1   6.5 225.4411382 0.002695262 0.022801391 0.062301021
02/18/2017  128 0   0   0   1   0   0   1   6.5 225.4411382 0.002666188 0.005619794 0.062272353
02/19/2017  129 0   0   0   1   0   0   1   6.5 225.4411382 0.002879882 0.005619794 0.062272353
02/19/2017  130 0   1   0   0   0   0   0   7.3 225.4411382 0.005188592 0.005619794 0.062272353
02/20/2017  131 0   1   0   1   0   0   1   6.5 225.4411382 0.003248565 0.005619794 0.062272353
02/21/2017  132 0   1   0   0   1   0   0   6.1 225.4411382 0.007379637 0.048719839 0.062261158
02/22/2017  133 0   0   0   1   0   0   1   6.5 225.4411382 0.002943242 0.013892505 0.062233763
02/22/2017  134 0   0   0   1   0   0   1   6.5 225.4411382 0.002943242 0.013892505 0.062233763
02/22/2017  135 0   0   1   1   0   0   0   6.1 225.4411382 0.006542636 0.013892505 0.062233763
02/22/2017  136 1   0   0   0   0   1   0   6.3 225.4411382 0.003502356 0.013892505 0.062233763
02/23/2017  137 0   1   0   1   0   0   1   6.5 225.4411382 0.002936277 0.019675489 0.062207849
02/23/2017  138 1   0   0   0   1   0   0   7.3 225.4411382 0.005512353 0.019675489 0.062207849
02/24/2017  139 0   0   0   1   0   0   0   6.1 225.4411382 0.006400431 0.018114563 0.062181535
02/24/2017  140 0   0   0   1   0   0   0   6.1 225.4411382 0.006400431 0.018114563 0.062181535
02/25/2017  141 0   1   0   1   0   0   1   6.5 225.4411382 0.002827164 0.014374927 0.062154355
02/25/2017  142 0   0   0   1   0   0   0   7.8 225.4411382 0.002229686 0.014374927 0.062154355
02/27/2017  143 0   1   0   1   0   0   1   6.5 225.4411382 0.003494087 0.014374927 0.062154355
02/27/2017  144 0   0   0   1   0   0   0   6.1 225.4411382 0.008110374 0.014374927 0.062154355
02/27/2017  145 0   0   0   0   1   0   0   6.3 225.4411382 0.008688621 0.014374927 0.062154355
02/27/2017  146 1   0   0   1   0   0   0   4.5 225.4411382 0.013588313 0.014374927 0.062154355
02/27/2017  147 1   0   0   0   1   0   0   5.3 225.4411382 0.004551333 0.014374927 0.062154355
02/28/2017  148 0   1   0   1   0   0   1   6.5 225.4411382 0.003137535 -0.00217941 0.062125715
02/28/2017  149 1   0   0   0   1   0   0   8.3 225.4411382 0.004169185 -0.00217941 0.062125715
03/01/2017  150 0   0   0   1   0   0   1   6.5 238.161619  0.002826907 0.024337051 0.062101474
03/01/2017  151 0   0   0   1   0   0   1   6.5 238.161619  0.002826907 0.024337051 0.062101474
03/01/2017  152 0   0   0   1   0   0   1   6.5 238.161619  0.002826907 0.024337051 0.062101474
03/01/2017  153 0   0   0   1   0   0   0   6.1 238.161619  0.007100868 0.024337051 0.062101474
03/01/2017  154 0   0   0   1   0   0   0   6.1 238.161619  0.007100868 0.024337051 0.062101474
03/01/2017  155 0   0   0   1   0   0   0   6.1 238.161619  0.007100868 0.024337051 0.062101474
03/01/2017  156 0   0   0   1   0   0   0   7.8 238.161619  0.00321752  0.024337051 0.062101474
03/01/2017  157 0   0   0   1   0   0   0   7.8 238.161619  0.00321752  0.024337051 0.062101474
03/01/2017  158 0   0   0   1   0   0   0   7.8 238.161619  0.00321752  0.024337051 0.062101474
03/02/2017  159 0   0   0   1   0   0   1   6.5 238.161619  0.003262569 0.049481385 0.062091033
03/02/2017  160 0   0   0   1   0   0   1   6.5 238.161619  0.003262569 0.049481385 0.062091033
03/02/2017  161 0   0   0   1   0   0   1   6.5 238.161619  0.003262569 0.049481385 0.062091033
03/02/2017  162 0   0   0   1   0   0   1   6.5 238.161619  0.003262569 0.049481385 0.062091033
03/02/2017  163 0   0   0   1   0   0   1   6.5 238.161619  0.003262569 0.049481385 0.062091033
03/02/2017  164 0   0   0   1   0   0   1   6.5 238.161619  0.003262569 0.049481385 0.062091033
03/02/2017  165 0   1   0   1   0   0   0   7.3 238.161619  0.005423948 0.049481385 0.062091033
03/02/2017  166 0   1   0   1   0   0   0   7.3 238.161619  0.005423948 0.049481385 0.062091033
03/02/2017  167 0   1   0   1   0   0   0   7.3 238.161619  0.005423948 0.049481385 0.062091033
03/03/2017  168 1   0   0   1   0   0   1   6.5 238.161619  0.003261096 -0.004402012    0.062062609
03/03/2017  169 1   0   0   1   0   0   1   6.5 238.161619  0.003261096 -0.004402012    0.062062609
03/03/2017  170 1   0   0   1   0   0   1   6.5 238.161619  0.003261096 -0.004402012    0.062062609
03/04/2017  171 0   0   0   1   0   0   0   5.8 238.161619  0.009462591 0.001234096 0.062034093
03/04/2017  172 0   0   0   1   0   0   0   5.8 238.161619  0.009462591 0.001234096 0.062034093
03/04/2017  173 0   0   0   1   0   0   0   5.8 238.161619  0.009462591 0.001234096 0.062034093
03/06/2017  174 0   0   0   1   0   0   1   6.5 238.161619  0.003904071 0.001234096 0.062034093
03/06/2017  175 0   0   0   1   0   0   1   6.5 238.161619  0.003904071 0.001234096 0.062034093
03/06/2017  176 0   0   0   1   0   0   1   6.5 238.161619  0.003904071 0.001234096 0.062034093
03/06/2017  177 0   0   0   1   0   0   1   6.5 238.161619  0.003904071 0.001234096 0.062034093
03/06/2017  178 0   0   0   1   0   0   1   6.5 238.161619  0.003904071 0.001234096 0.062034093
03/06/2017  179 0   0   0   1   0   0   1   6.5 238.161619  0.003904071 0.001234096 0.062034093
03/06/2017  180 0   0   0   1   0   0   0   6.1 238.161619  0.008682166 0.001234096 0.062034093
03/06/2017  181 0   0   0   1   0   0   0   6.1 238.161619  0.008682166 0.001234096 0.062034093
03/06/2017  182 0   0   0   1   0   0   0   6.1 238.161619  0.008682166 0.001234096 0.062034093
03/07/2017  183 0   1   0   1   0   0   1   6.5 238.161619  0.003368821 -0.018231974    0.062008065
03/07/2017  184 0   1   0   1   0   0   1   6.5 238.161619  0.003368821 -0.018231974    0.062008065
03/07/2017  185 0   1   0   1   0   0   1   6.5 238.161619  0.003368821 -0.018231974    0.062008065
03/08/2017  186 1   0   0   1   0   0   0   6.1 238.161619  0.006993576 -0.055975584    0.0620028
03/08/2017  187 1   0   0   1   0   0   0   6.1 238.161619  0.006993576 -0.055975584    0.0620028
03/08/2017  188 1   0   0   1   0   0   0   6.1 238.161619  0.006993576 -0.055975584    0.0620028
03/09/2017  189 0   0   0   1   0   0   0   5.7 238.161619  0.00637861  0.010374975 0.061975174
03/09/2017  190 0   0   0   1   0   0   0   5.7 238.161619  0.00637861  0.010374975 0.061975174
03/09/2017  191 0   0   0   1   0   0   0   5.7 238.161619  0.00637861  0.010374975 0.061975174
03/09/2017  192 0   1   0   1   0   0   0   6.3 238.161619  0.006919775 0.010374975 0.061975174
03/09/2017  193 0   1   0   1   0   0   0   6.3 238.161619  0.006919775 0.010374975 0.061975174
03/09/2017  194 0   1   0   1   0   0   0   6.3 238.161619  0.006919775 0.010374975 0.061975174
03/10/2017  195 0   1   0   1   0   0   0   6.7 238.161619  0.005170876 -0.086404737    0.062001949
03/10/2017  196 0   1   0   1   0   0   0   6.7 238.161619  0.005170876 -0.086404737    0.062001949
03/10/2017  197 0   1   0   1   0   0   0   6.7 238.161619  0.005170876 -0.086404737    0.062001949
03/11/2017  198 0   0   0   1   0   0   0   6.8 238.161619  0.004537821 0.120279563 0.062080276
03/11/2017  199 0   0   0   1   0   0   0   6.8 238.161619  0.004537821 0.120279563 0.062080276
03/11/2017  200 0   0   0   1   0   0   0   6.8 238.161619  0.004537821 0.120279563 0.062080276
03/11/2017  201 0   0   0   0   0   0   0   5.7 238.161619  0.004403423 0.120279563 0.062080276
03/11/2017  202 0   0   0   0   0   0   0   5.7 238.161619  0.004403423 0.120279563 0.062080276
03/11/2017  203 0   0   0   0   0   0   0   5.7 238.161619  0.004403423 0.120279563 0.062080276
03/12/2017  204 0   1   0   0   0   0   1   6.5 238.161619  0.002966075 0.120279563 0.062080276
03/12/2017  205 0   1   0   0   0   0   1   6.5 238.161619  0.002966075 0.120279563 0.062080276
03/12/2017  206 0   1   0   0   0   0   1   6.5 238.161619  0.002966075 0.120279563 0.062080276
03/13/2017  207 0   0   0   1   0   0   0   6.1 238.161619  0.008535417 0.120279563 0.062080276
03/13/2017  208 0   0   0   1   0   0   0   6.1 238.161619  0.008535417 0.120279563 0.062080276
03/13/2017  209 0   0   0   1   0   0   0   6.1 238.161619  0.008535417 0.120279563 0.062080276
03/13/2017  210 0   0   0   1   0   0   0   7.8 238.161619  0.004056711 0.120279563 0.062080276
03/13/2017  211 0   0   0   1   0   0   0   7.8 238.161619  0.004056711 0.120279563 0.062080276
03/13/2017  212 0   0   0   1   0   0   0   7.8 238.161619  0.004056711 0.120279563 0.062080276
03/14/2017  213 0   0   0   1   0   0   1   6.5 238.161619  0.002868652 0.008901032 0.06205248
03/14/2017  214 0   0   0   1   0   0   1   6.5 238.161619  0.002868652 0.008901032 0.06205248
03/14/2017  215 0   0   0   1   0   0   1   6.5 238.161619  0.002868652 0.008901032 0.06205248
03/14/2017  216 0   1   0   1   0   0   0   6.1 238.161619  0.007473939 0.008901032 0.06205248
03/14/2017  217 0   1   0   1   0   0   0   6.1 238.161619  0.007473939 0.008901032 0.06205248
03/14/2017  218 0   1   0   1   0   0   0   6.1 238.161619  0.007473939 0.008901032 0.06205248
03/14/2017  219 1   0   0   1   0   0   0   7.7 238.161619  0.006994721 0.008901032 0.06205248
03/14/2017  220 1   0   0   1   0   0   0   7.7 238.161619  0.006994721 0.008901032 0.06205248
03/14/2017  221 1   0   0   1   0   0   0   7.7 238.161619  0.006994721 0.008901032 0.06205248
03/14/2017  222 0   0   0   1   0   0   0   6.8 238.161619  0.010898931 0.008901032 0.06205248
03/14/2017  223 0   0   0   1   0   0   0   6.8 238.161619  0.010898931 0.008901032 0.06205248
03/14/2017  224 0   0   0   1   0   0   0   6.8 238.161619  0.010898931 0.008901032 0.06205248
03/15/2017  225 0   1   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  226 0   1   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  227 0   0   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  228 0   1   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  229 0   1   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  230 0   0   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  231 0   1   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  232 0   1   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  233 0   0   0   1   0   0   1   6.5 238.161619  0.002556912 -0.001296433    0.062024152
03/15/2017  234 0   0   0   1   0   0   0   6.1 238.161619  0.00638285  -0.001296433    0.062024152
03/15/2017  235 0   0   0   1   0   0   0   6.1 238.161619  0.00638285  -0.001296433    0.062024152
03/15/2017  236 0   0   0   1   0   0   0   6.1 238.161619  0.00638285  -0.001296433    0.062024152
03/15/2017  237 0   0   0   0   0   0   0   6.5 238.161619  0.014866991 -0.001296433    0.062024152
03/15/2017  238 0   0   0   0   0   0   0   6.5 238.161619  0.014866991 -0.001296433    0.062024152
03/15/2017  239 0   0   0   0   0   0   0   6.5 238.161619  0.014866991 -0.001296433    0.062024152
03/15/2017  240 0   0   0   1   0   0   0   7.7 238.161619  0.006218225 -0.001296433    0.062024152
03/15/2017  241 0   0   0   1   0   0   0   7.7 238.161619  0.006218225 -0.001296433    0.062024152
03/15/2017  242 0   0   0   1   0   0   0   7.7 238.161619  0.006218225 -0.001296433    0.062024152
04/01/2017  243 0   0   0   1   0   0   1   6.5 192.143176  0.002289305 0.058578409 0.061975502
04/01/2017  244 0   0   0   1   0   0   0   6.1 192.143176  0.005353254 0.058578409 0.061975502
04/02/2017  245 0   0   0   0   1   0   0   6   192.143176  0.003172046 0.058578409 0.061975502
04/03/2017  246 0   0   0   0   0   0   1   6.5 192.143176  0.002848748 0.058578409 0.061975502
04/03/2017  247 0   0   0   0   1   0   0   6.1 192.143176  0.006550344 0.058578409 0.061975502
04/03/2017  248 1   0   0   0   1   0   0   7.3 192.143176  0.007641192 0.058578409 0.061975502
04/03/2017  249 0   0   0   0   0   0   0   7.8 192.143176  0.004299388 0.058578409 0.061975502
04/04/2017  250 0   0   0   1   0   0   1   6.5 192.143176  0.002568017 -0.009146501    0.061948162
04/04/2017  251 0   1   0   0   1   0   0   6.1 192.143176  0.005894783 -0.009146501    0.061948162
04/04/2017  252 0   0   1   1   0   0   0   6.5 192.143176  0.012075672 -0.009146501    0.061948162
04/04/2017  253 0   0   1   1   0   0   0   6.7 192.143176  0.00728987  -0.009146501    0.061948162
04/04/2017  254 0   0   1   1   0   0   0   5.7 192.143176  0.010382549 -0.009146501    0.061948162
04/05/2017  255 0   0   0   0   1   0   1   6.5 192.143176  0.002292826 -0.007230556    0.061920632
04/05/2017  256 0   0   0   0   1   0   0   7.3 192.143176  0.005146235 -0.007230556    0.061920632
04/06/2017  257 1   0   0   1   0   0   1   6.5 192.143176  0.002294755 0.044621463 0.061907235
04/06/2017  258 0   0   0   0   1   0   1   6.5 192.143176  0.002294755 0.044621463 0.061907235
04/06/2017  259 0   0   0   1   0   0   0   6.1 192.143176  0.005304792 0.044621463 0.061907235
04/06/2017  260 0   0   0   0   1   0   0   6.1 192.143176  0.005304792 0.044621463 0.061907235
04/06/2017  261 0   0   0   1   0   0   0   6.1 192.143176  0.005304792 0.044621463 0.061907235
04/06/2017  262 0   0   0   1   0   0   0   6.1 192.143176  0.005304792 0.044621463 0.061907235
04/07/2017  263 0   1   0   1   0   0   1   6.5 192.143176  0.002301431 0.022833827 0.061883181
04/07/2017  264 0   0   0   1   0   0   1   6.5 192.143176  0.002301431 0.022833827 0.061883181
04/08/2017  265 1   0   0   1   0   0   1   6.5 192.143176  0.002278467 0.010542803 0.061856182
04/08/2017  266 1   0   0   1   0   0   1   6.5 192.143176  0.002278467 0.010542803 0.061856182
04/08/2017  267 0   0   0   0   1   0   0   6.1 192.143176  0.00522646  0.010542803 0.061856182
04/09/2017  268 0   1   0   1   0   0   0   7.8 192.143176  0.003720009 0.010542803 0.061856182
04/10/2017  269 0   1   0   1   0   0   1   6.5 192.143176  0.002842283 0.010542803 0.061856182
04/10/2017  270 0   0   0   1   0   0   0   6.1 192.143176  0.006367672 0.010542803 0.061856182
04/10/2017  271 1   0   0   0   1   0   0   6.1 192.143176  0.006367672 0.010542803 0.061856182
04/11/2017  272 0   0   1   1   0   0   0   7.3 192.143176  0.003752301 0.016406649 0.061830366
04/12/2017  273 0   0   0   1   0   0   0   7.8 192.143176  0.003363679 -0.011453291    0.061803585
04/13/2017  274 0   0   0   0   1   0   0   6.1 192.143176  0.004953876 -0.038904987    0.061786866
04/13/2017  275 0   0   0   1   0   0   0   6.1 192.143176  0.004953876 -0.038904987    0.061786866
04/13/2017  276 0   0   0   1   0   0   0   6.1 192.143176  0.004953876 -0.038904987    0.061786866
04/13/2017  277 0   1   0   1   0   0   0   5.7 192.143176  0.005242642 -0.038904987    0.061786866
04/14/2017  278 0   1   0   1   0   0   1   6.5 192.143176  0.00227121  0.010274397 0.061759967
04/14/2017  279 1   0   0   0   1   0   1   6.5 192.143176  0.00227121  0.010274397 0.061759967
04/14/2017  280 0   0   0   1   0   0   0   6.1 192.143176  0.005054546 0.010274397 0.061759967
04/14/2017  281 0   0   0   1   0   0   0   7.8 192.143176  0.00321436  0.010274397 0.061759967
04/15/2017  282 0   1   0   1   0   0   0   4.3 192.143176  0.005754067 0.043387372 0.061472759
05/11/2017  283 0   0   0   0   0   1   0   6.1 193.7951124 0.007689064 0.043387372 0.061472759
05/17/2017  284 0   1   0   1   0   0   1   6.5 193.7951124 0.002436707 0.034476265 0.061448786
05/17/2017  285 0   1   0   1   0   0   0   7.3 193.7951124 0.004911254 0.034476265 0.061448786
05/17/2017  286 1   0   0   0   1   0   0   7.8 193.7951124 0.004096965 0.034476265 0.061448786
05/18/2017  287 1   0   0   0   1   0   1   6.5 193.7951124 0.003189772 0.017341108 0.061423998
05/18/2017  288 0   0   0   1   0   0   1   6.5 193.7951124 0.003189772 0.017341108 0.061423998
05/18/2017  289 0   0   0   1   0   0   1   6.5 193.7951124 0.003189772 0.017341108 0.061423998
05/18/2017  290 0   1   0   1   0   0   1   6.5 193.7951124 0.003189772 0.017341108 0.061423998
05/19/2017  291 0   0   0   1   0   0   1   6.5 193.7951124 0.003154391 0.037870468 0.061407325
05/19/2017  292 0   0   0   1   0   0   0   5.7 193.7951124 0.005666468 0.037870468 0.061407325
05/22/2017  293 1   0   0   1   0   0   1   6.5 193.7951124 0.004100766 0.12857387  0.061498158
05/22/2017  294 0   0   0   1   0   0   0   6.1 193.7951124 0.009390091 0.12857387  0.061498158
05/23/2017  295 0   0   0   1   0   0   0   6.1 193.7951124 0.008675658 -0.004746832    0.061471434
05/24/2017  296 0   0   0   1   0   0   0   4.5 193.7951124 0.005126083 0.099657893 0.061515128
05/25/2017  297 0   0   0   1   0   0   1   6.5 193.7951124 0.003339505 0.035502091 0.061497226
05/25/2017  298 0   0   0   0   1   0   0   6.1 193.7951124 0.007756978 0.035502091 0.061497226
05/25/2017  299 0   0   0   1   0   0   0   6.1 193.7951124 0.007756978 0.035502091 0.061497226
05/25/2017  300 0   0   0   1   0   0   0   6.1 193.7951124 0.007756978 0.035502091 0.061497226
05/26/2017  301 0   1   0   0   1   0   1   6.5 193.7951124 0.003085032 -0.101459299    0.061543369
05/26/2017  302 0   0   0   1   0   0   1   6.5 193.7951124 0.003085032 -0.101459299    0.061543369
05/28/2017  303 0   0   0   1   0   0   1   6.5 193.7951124 0.003484565 -0.000561184    0.061516561
05/28/2017  304 0   0   0   1   0   0   1   6.5 193.7951124 0.003484565 -0.000561184    0.061516561
05/29/2017  305 0   1   0   1   0   0   0   7.8 193.7951124 0.005669722 -0.000561184    0.061516561
05/30/2017  306 0   1   0   1   0   0   0   5.7 193.7951124 0.004592405 -0.002635929    0.061489835
05/31/2017  307 0   1   0   1   0   0   1   6.5 193.7951124 0.003430203 0.016047688 0.061464916
05/31/2017  308 0   1   0   1   0   0   1   6.5 193.7951124 0.003430203 0.016047688 0.061464916
05/31/2017  309 0   0   0   1   0   0   1   6.5 193.7951124 0.003430203 0.016047688 0.061464916
05/31/2017  310 0   0   0   1   0   0   1   6.5 193.7951124 0.003430203 0.016047688 0.061464916
05/31/2017  311 0   1   0   1   0   0   0   5.7 193.7951124 0.004127883 0.016047688 0.061464916
06/01/2017  312 0   0   0   1   0   0   1   6.5 162.775725  0.003417502 0.024917169 0.061442599
06/01/2017  313 0   0   0   1   0   0   0   6.1 162.775725  0.007080266 0.024917169 0.061442599
06/01/2017  314 0   1   0   1   0   0   0   7.3 162.775725  0.00701196  0.024917169 0.061442599
06/02/2017  315 0   0   0   1   0   0   1   6.5 162.775725  0.003507411 0.031259461 0.061422831
06/03/2017  316 0   1   0   1   0   0   1   6.5 162.775725  0.003517714 0.066697292 0.061427601
06/04/2017  317 0   1   0   1   0   0   1   6.5 162.775725  0.003937552 0.066697292 0.061427601
06/05/2017  318 1   0   0   0   0   1   1   6.5 162.775725  0.0043644   0.066697292 0.061427601
06/05/2017  319 0   1   0   1   0   0   0   6.3 162.775725  0.00824234  0.066697292 0.061427601
06/05/2017  320 0   0   0   1   0   0   0   5.7 162.775725  0.008702711 0.066697292 0.061427601
06/06/2017  321 0   0   0   0   1   0   0   6.1 162.775725  0.007922447 0.052613094 0.061420511
06/06/2017  322 1   0   0   0   0   1   0   6.3 162.775725  0.009758651 0.052613094 0.061420511
06/07/2017  323 0   0   0   1   0   0   1   6.5 162.775725  0.003552459 0.02689817  0.061399017
06/07/2017  324 0   0   0   0   1   0   0   6.1 162.775725  0.007161047 0.02689817  0.061399017
06/07/2017  325 0   0   0   1   0   0   0   7.8 162.775725  0.004616254 0.02689817  0.061399017
06/08/2017  326 0   0   0   1   0   0   0   6.1 162.775725  0.007041075 -0.0256721  0.0613771
06/08/2017  327 0   1   0   1   0   0   0   6   162.775725  0.009447309 -0.0256721  0.0613771
06/08/2017  328 0   1   0   1   0   0   0   4.5 162.775725  0.010965946 -0.0256721  0.0613771
06/09/2017  329 0   1   0   1   0   0   1   6.5 162.775725  0.003525695 0.033089851 0.061358282
06/09/2017  330 0   1   0   1   0   0   1   6.5 162.775725  0.003525695 0.033089851 0.061358282
06/09/2017  331 0   0   0   1   0   0   0   6.1 162.775725  0.007052294 0.033089851 0.061358282
06/09/2017  332 0   0   0   1   0   0   0   4.3 162.775725  0.005566463 0.033089851 0.061358282
06/12/2017  333 0   1   0   1   0   0   1   6.5 162.775725  0.004386692 -0.062218475    0.06135903
06/13/2017  334 1   0   0   0   0   1   1   6.5 162.775725  0.003957777 0.029925651 0.061338852
06/14/2017  335 0   0   0   0   0   1   1   6.5 162.775725  0.00353442  -0.072266186    0.061349111
06/14/2017  336 0   0   0   1   0   0   1   6.5 162.775725  0.00353442  -0.072266186    0.061349111
06/14/2017  337 0   0   0   1   0   0   0   6.1 162.775725  0.006936653 -0.072266186    0.061349111
06/14/2017  338 0   0   1   1   0   0   0   7.3 162.775725  0.00475144  -0.072266186    0.061349111
06/14/2017  339 0   1   0   1   0   0   0   7.3 162.775725  0.005299061 -0.072266186    0.061349111
06/15/2017  340 0   1   0   1   0   0   0   6.1 162.775725  0.006977155 -0.093505294    0.061384056
06/15/2017  341 0   0   0   1   0   0   0   8.3 162.775725  0.002227637 -0.093505294    0.061384056
06/15/2017  342 0   0   0   1   0   0   0   7.8 162.775725  0.004187896 -0.093505294    0.061384056
06/15/2017  343 0   0   0   1   0   0   0   7.8 162.775725  0.004187896 -0.093505294    0.061384056

After the error message, I tried using 'traceback()' command and found the following:

 traceback()
 4: pmodel.response.pFormula(formula, data, model = model, effect = effect, 
        theta = theta)
 3: pmodel.response(formula, data, model = model, effect = effect, 
        theta = theta)
 2: plm.fit(formula, data, model, effect, random.method, random.dfcor, 
        inst.method)
 1: plm(y ~ x1 + x2 + x3 + x4 * x7 + x5 * x7 + x6 * x7 + 
        x8 + x9 + x10 + x11, DATA, index = c("year", "id"), model = "within"

May I ask for help on this?
Or can anyone try this code with this given data and figure out why it is giving such an error?


回答1:


There's a couple things going on here, so here's is a multi-part answer.

1. Error Explanation

This error occurs because the data contained in your column "y" has many consecutively repeating values. There's only 82 unique "y" values in your sample dataset of 343 rows, and many of those values repeat 3 or 4 times in a row. This presents a problem for estimating a model with plm.

To test this, try filling "y" with values which do not repeat in that way; the error will disappear.

DATA$y <- rnorm(343)

plm(y ~ x1+x2+x3+x4*x7+x5*x7+x6*x7+x8+x9+x10+x11,
    DATA,index=c("Date","ID"),model="within")

Output:

Model Formula: y ~ x1 + x2 + x3 + x4 * x7 + x5 * x7 + x6 * x7 + x8 + x9 + x10 + x11

Coefficients:
         x1          x2          x3          x4          x7          x5 
  0.0266245  -0.0085766   0.6009325  -0.2500684  -1.0461660   0.1972594 
         x6          x8         x10       x4:x7       x7:x5       x7:x6 
  0.0668570   0.0432360 -85.6184702   0.8044105   0.9602976   0.5484500 

As another example, try replacing y with x9, a column which also happens to have a lot of consecutively repeating values. Doing so will produce the same error as in the original "y" case.

2. PLM Application Tips

Now that the main error is explained, there's a few extra points to mention.

The index argument for plm is typically in the reverse order: index=c("ID","Date") instead of index=c("Date","ID"). So that seems like a red flag. I don't know what hypothesis you're testing, but there are a couple tips I can still mention without knowing that.

If "Date" is being treated as the ID index and the "ID" column is being treated as the time index, then you'd need to set it up like this:

      Date  ID
01/01/2017   1
01/01/2017   2
01/02/2017   1
01/02/2017   2
01/03/2017   1
01/03/2017   2

That scenario seems unlikely though, given that all the IDs in the sample data appear only once. That suggests that this isn't a repeated measures analysis, which means that the order of the index probably should be index=c("ID","Date") and the model probably should be set to "between" not "within" if there's only one observation per "ID" column value. If this second scenario seems true for your case, then try this instead:

plm(y ~ x1+x2+x3+x4*x7+x5*x7+x6*x7+x8+x9+x10+x11,
    DATA,index=c("ID","Date"),model="between")


来源:https://stackoverflow.com/questions/46604729/error-in-plm-function-names-attribute-343-must-be-the-same-length-as-the-ve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!