Running ‘test_Chow.R’ [1s/2s]
  Comparing ‘test_Chow.Rout’ to ‘test_Chow.Rout.save’ ... OK
  Running ‘test_Errors.R’ [1s/1s]
  Comparing ‘test_Errors.Rout’ to ‘test_Errors.Rout.save’ ... OK
  Running ‘test_Estimators.R’ [4s/5s]
  Running ‘test_Evaluation.R’ [1s/2s]
  Comparing ‘test_Evaluation.Rout’ to ‘test_Evaluation.Rout.save’ ... OK
  Running ‘test_FD_models.R’ [1s/2s]
  Comparing ‘test_FD_models.Rout’ to ‘test_FD_models.Rout.save’ ... OK
  Running ‘test_IV.R’ [3s/5s]
  Comparing ‘test_IV.Rout’ to ‘test_IV.Rout.save’ ... OK
  Running ‘test_R2_adj_R2.R’ [1s/1s]
  Running ‘test_as.data.frame_as.matrix.R’ [1s/1s]
  Running ‘test_as.list.pdata.frame.R’ [1s/2s]
  Running ‘test_clubSandwich_interoperability.R’ [2s/3s]
  Comparing ‘test_clubSandwich_interoperability.Rout’ to ‘test_clubSandwich_interoperability.Rout.save’ ... OK
  Running ‘test_detect_lin_dep_alias.R’ [2s/4s]
  Running ‘test_fitted.plm.R’ [1s/2s]
  Running ‘test_fixef.R’ [1s/2s]
  Running ‘test_fixef_comp_lm_plm.R’ [1s/2s]
  Running ‘test_groupGenerics_pseries.R’ [1s/2s]
  Comparing ‘test_groupGenerics_pseries.Rout’ to ‘test_groupGenerics_pseries.Rout.save’ ...1153c1153
<  'pseries' Named num [1:200] 0.367879 0.084224 0.061313 0.033737 0.000454 ...
---
>  'pseries' Named num [1:200] 0.000454 0.00227 0.224042 0.033737 0.006383 ...
  Running ‘test_is.pconsecutive.R’ [1s/2s]
  Running ‘test_lag_lead.R’ [1s/1s]
  Comparing ‘test_lag_lead.Rout’ to ‘test_lag_lead.Rout.save’ ... OK
  Running ‘test_lagt_leadt.R’ [1s/2s]
  Comparing ‘test_lagt_leadt.Rout’ to ‘test_lagt_leadt.Rout.save’ ... OK
  Running ‘test_make.pconsecutive_pbalanced.R’ [1s/2s]
  Running ‘test_misc.R’ [1s/2s]
  Running ‘test_model.frame.R’ [1s/2s]
  Running ‘test_model.matrix_effects.R’ [1s/2s]
  Running ‘test_model.matrix_pmodel.response.R’ [1s/2s]
  Running ‘test_model.matrix_pmodel.response_NA.R’ [2s/3s]
  Running ‘test_nested.R’ [1s/3s]
  Comparing ‘test_nested.Rout’ to ‘test_nested.Rout.save’ ... OK
  Running ‘test_pFtest.R’ [1s/2s]
  Comparing ‘test_pFtest.Rout’ to ‘test_pFtest.Rout.save’ ... OK
  Running ‘test_pbgtest.R’ [2s/2s]
  Running ‘test_pbnftest.R’ [1s/2s]
  Comparing ‘test_pbnftest.Rout’ to ‘test_pbnftest.Rout.save’ ... OK
  Running ‘test_pbsytest_unbalanced.R’ [1s/2s]
  Comparing ‘test_pbsytest_unbalanced.Rout’ to ‘test_pbsytest_unbalanced.Rout.save’ ... OK
  Running ‘test_pcdtest.R’ [1s/2s]
  Running ‘test_pdata.frame_const_allNA_nonfinite.R’ [1s/2s]
  Running ‘test_pdata.frame_extract_class_est_mod.R’ [1s/2s]
  Running ‘test_pdata.frame_id_index_more.R’ [1s/2s]
  Running ‘test_pdata.frame_print_duplicated_rownames.R’ [1s/2s]
  Running ‘test_pdata.frame_subsetting.R’ [1s/2s]
  Comparing ‘test_pdata.frame_subsetting.Rout’ to ‘test_pdata.frame_subsetting.Rout.save’ ... OK
  Running ‘test_pdata.frame_unused_levels.R’ [1s/1s]
  Running ‘test_pdiff_fd.R’ [1s/1s]
  Running ‘test_pdwtest.R’ [1s/2s]
  Running ‘test_pggls.R’ [0s/1s]
  Running ‘test_pgmm.R’ [3s/5s]
  Comparing ‘test_pgmm.Rout’ to ‘test_pgmm.Rout.save’ ... OK
  Running ‘test_pgrangertest.R’ [2s/2s]
  Comparing ‘test_pgrangertest.Rout’ to ‘test_pgrangertest.Rout.save’ ... OK
  Running ‘test_pht.R’ [5s/6s]
  Comparing ‘test_pht.Rout’ to ‘test_pht.Rout.save’ ... OK
  Running ‘test_phtest_Hausman_regression.R’ [2s/3s]
  Comparing ‘test_phtest_Hausman_regression.Rout’ to ‘test_phtest_Hausman_regression.Rout.save’ ... OK
  Running ‘test_plm.data.R’ [1s/1s]
  Running ‘test_plm_na.action.R’ [1s/2s]
  Running ‘test_plmtest_unbalanced.R’ [1s/2s]
  Comparing ‘test_plmtest_unbalanced.Rout’ to ‘test_plmtest_unbalanced.Rout.save’ ... OK
  Running ‘test_preserve_rownames.R’ [1s/2s]
  Running ‘test_pseries_subsetting.R’ [1s/1s]
  Running ‘test_punbalancedness.R’ [1s/2s]
  Running ‘test_purtest.R’ [1s/2s]
  Comparing ‘test_purtest.Rout’ to ‘test_purtest.Rout.save’ ... OK
  Running ‘test_pvar.R’ [1s/2s]
  Running ‘test_pvcm.R’ [1s/2s]
  Comparing ‘test_pvcm.Rout’ to ‘test_pvcm.Rout.save’ ... OK
  Running ‘test_pwaldtest.R’ [1s/2s]
  Comparing ‘test_pwaldtest.Rout’ to ‘test_pwaldtest.Rout.save’ ... OK
  Running ‘test_pwaldtest_vcovG_attr_cluster.R’ [2s/4s]
  Comparing ‘test_pwaldtest_vcovG_attr_cluster.Rout’ to ‘test_pwaldtest_vcovG_attr_cluster.Rout.save’ ... OK
  Running ‘test_pwfdtest_pwartest.R’ [1s/2s]
  Running ‘test_pwtest.R’ [1s/2s]
  Running ‘test_ranef.R’ [2s/3s]
  Comparing ‘test_ranef.Rout’ to ‘test_ranef.Rout.save’ ... OK
  Running ‘test_residuals_overall_fitted_exp.R’ [2s/3s]
  Running ‘test_summary.plm_vcov.R’ [1s/2s]
  Running ‘test_summary.pseries_character_logical_factor.R’ [1s/1s]
  Running ‘test_vcovG_lin_dep.R’ [2s/3s]
  Running ‘test_within_intercept.R’ [1s/2s]
  Comparing ‘test_within_intercept.Rout’ to ‘test_within_intercept.Rout.save’ ... OK
Running the tests in ‘tests/test_Estimators.R’ failed.
Complete output:
  > #### Replicate results of various sources and additional run tests, compared to the corresponding .Rout.save
  > ####
  > #### (1): Baltagi (2013)
  > #### (2): Stata's FE estimator
  > #### (3): test of unbalanced one-way RE Swamy/Arora on Hedonic data set
  > 
  > #### (1) ####
  > #### compare OLS, FE and RE estimators to Baltagi's results
  > # Baltagi (2013), Econometric Analysis of Panel Data, 5th edition, Wiley & Sons
  > #    oneway:  sec. 2.6, example 1 p. 27, table 2.1
  > #    twoways: sec. 3.6, example 1 p. 51, table 3.1
  > #
  > # = Baltagi (2005), p. 21 (oneway), p. 43 (twoways) 
  > 
  > # Table 2.1 Grunfeld's Data One-way Error Component Results
  > #           beta1     beta2   rho  sigma_me sigma_nu
  > #--------------------------------------------------
  > # [...]
  > 
  > library(plm)
  Loading required package: Formula
  > data("Grunfeld", package = "plm")
  > Grunfeld_unbal <- Grunfeld[1:199, ]
  > 
  > #### oneway individual balanced
  > plm_grunfeld_pooled     <- plm(inv ~ value + capital, data=Grunfeld, model="pooling")
  > plm_grunfeld_be         <- plm(inv ~ value + capital, data=Grunfeld, model="between")
  > plm_grunfeld_fe         <- plm(inv ~ value + capital, data=Grunfeld, model="within")
  > plm_grunfeld_re_walhus  <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="walhus")
  > plm_grunfeld_re_amemiya <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="amemiya")
  > plm_grunfeld_re_swar    <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="swar")
  > plm_grunfeld_re_nerlove <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="nerlove")
  > 
  > summary(plm_grunfeld_pooled    )
  Pooling Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "pooling")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.6757  -30.0137    5.3033   34.8293  369.4464 
  
  Coefficients:
                 Estimate  Std. Error t-value  Pr(>|t|)    
  (Intercept) -42.7143694   9.5116760 -4.4907 1.207e-05 ***
  value         0.1155622   0.0058357 19.8026 < 2.2e-16 ***
  capital       0.2306785   0.0254758  9.0548 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9359900
  Residual Sum of Squares: 1755900
  R-Squared:      0.81241
  Adj. R-Squared: 0.8105
  F-statistic: 426.576 on 2 and 197 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_be        )
  Oneway (individual) effect Between Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "between")
  
  Balanced Panel: n = 10, T = 20, N = 200
  Observations used in estimation: 10
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -163.3924   -3.6808    2.9683   20.7388  144.0590 
  
  Coefficients:
               Estimate Std. Error t-value Pr(>|t|)   
  (Intercept) -8.527114  47.515308 -0.1795  0.86266   
  value        0.134646   0.028745  4.6841  0.00225 **
  capital      0.032031   0.190938  0.1678  0.87152   
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    355780
  Residual Sum of Squares: 50603
  R-Squared:      0.85777
  Adj. R-Squared: 0.81713
  F-statistic: 21.1077 on 2 and 7 DF, p-value: 0.0010851
  > summary(plm_grunfeld_fe        )
  Oneway (individual) effect Within Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "within")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Residuals:
        Min.    1st Qu.     Median    3rd Qu.       Max. 
  -184.00857  -17.64316    0.56337   19.19222  250.70974 
  
  Coefficients:
          Estimate Std. Error t-value  Pr(>|t|)    
  value   0.110124   0.011857  9.2879 < 2.2e-16 ***
  capital 0.310065   0.017355 17.8666 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2244400
  Residual Sum of Squares: 523480
  R-Squared:      0.76676
  Adj. R-Squared: 0.75311
  F-statistic: 309.014 on 2 and 188 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_walhus )
  Oneway (individual) effect Random Effect Model 
     (Wallace-Hussain's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "random", 
      random.method = "walhus")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 3089.07   55.58 0.352
  individual    5690.18   75.43 0.648
  theta: 0.8374
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -181.3556  -22.0352    5.7851   18.8320  253.9807 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.553864  25.335537 -2.2717  0.02311 *  
  value         0.109710   0.010181 10.7756  < 2e-16 ***
  capital       0.307374   0.017272 17.7959  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2432400
  Residual Sum of Squares: 558340
  R-Squared:      0.77046
  Adj. R-Squared: 0.76813
  Chisq: 661.224 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_swar   )
  Oneway (individual) effect Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "random", 
      random.method = "swar")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 2784.46   52.77 0.282
  individual    7089.80   84.20 0.718
  theta: 0.8612
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -177.6063  -19.7350    4.6851   19.5105  252.8743 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.834415  28.898935 -2.0013  0.04536 *  
  value         0.109781   0.010493 10.4627  < 2e-16 ***
  capital       0.308113   0.017180 17.9339  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2381400
  Residual Sum of Squares: 548900
  R-Squared:      0.7695
  Adj. R-Squared: 0.76716
  Chisq: 657.674 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_amemiya)
  Oneway (individual) effect Random Effect Model 
     (Amemiya's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "random", 
      random.method = "amemiya")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 2755.15   52.49 0.298
  individual    6477.30   80.48 0.702
  theta: 0.8557
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -178.4834  -20.1692    4.9156   19.5200  253.1136 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.771054  27.961477 -2.0661  0.03882 *  
  value         0.109764   0.010421 10.5328  < 2e-16 ***
  capital       0.307952   0.017200 17.9039  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2392500
  Residual Sum of Squares: 550970
  R-Squared:      0.76971
  Adj. R-Squared: 0.76738
  Chisq: 658.458 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_nerlove)
  Oneway (individual) effect Random Effect Model 
     (Nerlove's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, model = "random", 
      random.method = "nerlove")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 2617.39   51.16 0.263
  individual    7350.06   85.73 0.737
  theta: 0.8677
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -176.5695  -19.8094    4.5578   19.4083  252.6067 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.907362  30.106995 -1.9234  0.05443 .  
  value         0.109802   0.010576 10.3824  < 2e-16 ***
  capital       0.308294   0.017158 17.9676  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2368800
  Residual Sum of Squares: 546580
  R-Squared:      0.76926
  Adj. R-Squared: 0.76692
  Chisq: 656.784 on 2 DF, p-value: < 2.22e-16
  > 
  > #### oneway time balanced
  > plm_grunfeld_be_time         <- plm(inv ~ value + capital, data=Grunfeld, model="between", effect = "time")
  > plm_grunfeld_fe_time         <- plm(inv ~ value + capital, data=Grunfeld, model="within",  effect = "time")
  > plm_grunfeld_re_walhus_time  <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="walhus",  effect = "time")
  > plm_grunfeld_re_amemiya_time <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="amemiya", effect = "time")
  > plm_grunfeld_re_swar_time    <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="swar",    effect = "time")
  > plm_grunfeld_re_nerlove_time <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="nerlove", effect = "time")
  > 
  > summary(plm_grunfeld_be_time        )
  Oneway (time) effect Between Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "time", 
      model = "between")
  
  Balanced Panel: n = 10, T = 20, N = 200
  Observations used in estimation: 20
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -33.94030  -7.93792  -0.56437   9.84984  19.53850 
  
  Coefficients:
                Estimate Std. Error t-value  Pr(>|t|)    
  (Intercept) -33.224601  19.412274 -1.7115 0.1051660    
  value         0.099252   0.020102  4.9374 0.0001249 ***
  capital       0.260214   0.024576 10.5879 6.659e-09 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    62870
  Residual Sum of Squares: 3839.6
  R-Squared:      0.93893
  Adj. R-Squared: 0.93174
  F-statistic: 130.682 on 2 and 17 DF, p-value: 4.7819e-11
  > summary(plm_grunfeld_fe_time        )
  Oneway (time) effect Within Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "time", 
      model = "within")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -292.1576  -26.3717    8.3651   31.4250  380.1370 
  
  Coefficients:
           Estimate Std. Error t-value  Pr(>|t|)    
  value   0.1167978  0.0063313 18.4477 < 2.2e-16 ***
  capital 0.2197066  0.0322961  6.8029 1.504e-10 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    8731200
  Residual Sum of Squares: 1713000
  R-Squared:      0.80381
  Adj. R-Squared: 0.78067
  F-statistic: 364.645 on 2 and 178 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_walhus_time )
  Oneway (time) effect Random Effect Model 
     (Wallace-Hussain's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "time", 
      model = "random", random.method = "walhus")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 9522.69   97.58     1
  time             0.00    0.00     0
  theta: 0
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.6757  -30.0137    5.3033   34.8293  369.4464 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -42.7143694   9.5116760 -4.4907 7.098e-06 ***
  value         0.1155622   0.0058357 19.8026 < 2.2e-16 ***
  capital       0.2306785   0.0254758  9.0548 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9359900
  Residual Sum of Squares: 1755900
  R-Squared:      0.81241
  Adj. R-Squared: 0.8105
  Chisq: 853.151 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_swar_time   )
  Oneway (time) effect Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "time", 
      model = "random", random.method = "swar")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                   var std.dev share
  idiosyncratic 9623.4    98.1     1
  time             0.0     0.0     0
  theta: 0
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.6757  -30.0137    5.3033   34.8293  369.4464 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -42.7143694   9.5116760 -4.4907 7.098e-06 ***
  value         0.1155622   0.0058357 19.8026 < 2.2e-16 ***
  capital       0.2306785   0.0254758  9.0548 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9359900
  Residual Sum of Squares: 1755900
  R-Squared:      0.81241
  Adj. R-Squared: 0.8105
  Chisq: 853.151 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_amemiya_time)
  Oneway (time) effect Random Effect Model 
     (Amemiya's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "time", 
      model = "random", random.method = "amemiya")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 9516.51   97.55     1
  time             0.00    0.00     0
  theta: 0
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.6757  -30.0137    5.3033   34.8293  369.4464 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -42.7143694   9.5116760 -4.4907 7.098e-06 ***
  value         0.1155622   0.0058357 19.8026 < 2.2e-16 ***
  capital       0.2306785   0.0254758  9.0548 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9359900
  Residual Sum of Squares: 1755900
  R-Squared:      0.81241
  Adj. R-Squared: 0.8105
  Chisq: 853.151 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_nerlove_time)
  Oneway (time) effect Random Effect Model 
     (Nerlove's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "time", 
      model = "random", random.method = "nerlove")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 8564.86   92.55 0.973
  time           234.38   15.31 0.027
  theta: 0.1139
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.2135  -28.3774    5.6538   34.4465  371.6054 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -42.4667890  10.1886847 -4.1680 3.072e-05 ***
  value         0.1157687   0.0058638 19.7429 < 2.2e-16 ***
  capital       0.2289722   0.0263535  8.6885 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9224900
  Residual Sum of Squares: 1746800
  R-Squared:      0.81064
  Adj. R-Squared: 0.80872
  Chisq: 843.335 on 2 DF, p-value: < 2.22e-16
  > 
  > #### oneway individual unbalanced
  > plm_grunfeld_be_unbal         <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="between")
  > plm_grunfeld_fe_unbal         <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="within")
  > plm_grunfeld_re_walhus_unbal  <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="walhus")
  > plm_grunfeld_re_amemiya_unbal <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="amemiya")
  > plm_grunfeld_re_swar_unbal    <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="swar")
  > ## not implemented
  > # plm_grunfeld_re_nerlove_unbal <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="nerlove")
  > 
  > summary(plm_grunfeld_be_unbal        )
  Oneway (individual) effect Between Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, model = "between")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  Observations used in estimation: 10
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -163.3896   -3.6615    2.9251   20.7200  144.0777 
  
  Coefficients:
               Estimate Std. Error t-value Pr(>|t|)   
  (Intercept) -8.583114  47.497067 -0.1807  0.86172   
  value        0.134642   0.028744  4.6843  0.00225 **
  capital      0.032182   0.190854  0.1686  0.87086   
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    355810
  Residual Sum of Squares: 50602
  R-Squared:      0.85778
  Adj. R-Squared: 0.81715
  F-statistic: 21.1102 on 2 and 7 DF, p-value: 0.0010848
  > summary(plm_grunfeld_fe_unbal        )
  Oneway (individual) effect Within Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, model = "within")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Residuals:
        Min.    1st Qu.     Median    3rd Qu.       Max. 
  -184.00854  -17.86458    0.53588   19.33777  250.71052 
  
  Coefficients:
          Estimate Std. Error t-value  Pr(>|t|)    
  value   0.110125   0.011888  9.2632 < 2.2e-16 ***
  capital 0.310064   0.017401 17.8188 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2244300
  Residual Sum of Squares: 523480
  R-Squared:      0.76676
  Adj. R-Squared: 0.75304
  F-statistic: 307.37 on 2 and 187 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_walhus_unbal )
  Oneway (individual) effect Random Effect Model 
     (Wallace-Hussain's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, model = "random", 
      random.method = "walhus")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 2900.88   53.86 0.275
  individual    7663.69   87.54 0.725
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.8602  0.8637  0.8637  0.8634  0.8637  0.8637 
  
  Residuals:
      Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  -177.211  -19.802    4.641   -0.017   19.687  252.771 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.874183  29.422867  -1.967  0.04919 *  
  value         0.109792   0.010552  10.405  < 2e-16 ***
  capital       0.308181   0.017216  17.901  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2376100
  Residual Sum of Squares: 548000
  R-Squared:      0.76937
  Adj. R-Squared: 0.76702
  Chisq: 653.862 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_swar_unbal   )
  Oneway (individual) effect Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, model = "random", 
      random.method = "swar")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 2799.34   52.91 0.282
  individual    7124.82   84.41 0.718
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.8577  0.8612  0.8612  0.8609  0.8612  0.8612 
  
  Residuals:
      Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  -177.611  -19.815    4.769   -0.018   19.686  252.876 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.846046  28.969526 -1.9968  0.04585 *  
  value         0.109784   0.010519 10.4364  < 2e-16 ***
  capital       0.308110   0.017224 17.8880  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2381000
  Residual Sum of Squares: 548910
  R-Squared:      0.76947
  Adj. R-Squared: 0.76711
  Chisq: 654.203 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_amemiya_unbal)
  Oneway (individual) effect Random Effect Model 
     (Amemiya's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, model = "random", 
      random.method = "amemiya")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 2799.34   52.91 0.286
  individual    6994.34   83.63 0.714
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.8564  0.8599  0.8599  0.8596  0.8599  0.8599 
  
  Residuals:
      Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  -177.811  -19.945    4.834   -0.018   19.678  252.929 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.831814  28.748169 -2.0117  0.04425 *  
  value         0.109780   0.010503 10.4523  < 2e-16 ***
  capital       0.308074   0.017229 17.8813  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2383500
  Residual Sum of Squares: 549370
  R-Squared:      0.76951
  Adj. R-Squared: 0.76716
  Chisq: 654.377 on 2 DF, p-value: < 2.22e-16
  > # summary(plm_grunfeld_re_nerlove_unbal) # not implemented
  > 
  > #### oneway time unbalanced
  > plm_grunfeld_be_time_unbal         <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="between", effect = "time")
  > plm_grunfeld_fe_time_unbal         <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="within",  effect = "time")
  > plm_grunfeld_re_walhus_time_unbal  <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="walhus",  effect = "time")
  > plm_grunfeld_re_amemiya_time_unbal <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="amemiya", effect = "time")
  > plm_grunfeld_re_swar_time_unbal    <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="swar",    effect = "time")
  > ## not implemented:
  > # plm_grunfeld_re_nerlove_time_unbal <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="nerlove", effect = "time")
  > 
  > summary(plm_grunfeld_be_time_unbal        )
  Oneway (time) effect Between Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "time", 
      model = "between")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  Observations used in estimation: 20
  
  Residuals:
      Min.  1st Qu.   Median  3rd Qu.     Max. 
  -34.0155  -8.0472  -0.2581   9.7594  18.9273 
  
  Coefficients:
                Estimate Std. Error t-value  Pr(>|t|)    
  (Intercept) -30.984895  18.541321 -1.6711 0.1130019    
  value         0.097527   0.019623  4.9700 0.0001167 ***
  capital       0.258281   0.024649 10.4782 7.774e-09 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    71348
  Residual Sum of Squares: 3870
  R-Squared:      0.94576
  Adj. R-Squared: 0.93938
  F-statistic: 148.209 on 2 and 17 DF, p-value: 1.7449e-11
  > summary(plm_grunfeld_fe_time_unbal        )
  Oneway (time) effect Within Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "time", 
      model = "within")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -288.9732  -27.3836    8.3436   31.6945  380.9448 
  
  Coefficients:
           Estimate Std. Error t-value  Pr(>|t|)    
  value   0.1167471  0.0063489 18.3887 < 2.2e-16 ***
  capital 0.2215911  0.0328505  6.7454 2.088e-10 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    8651000
  Residual Sum of Squares: 1711900
  R-Squared:      0.80212
  Adj. R-Squared: 0.77864
  F-statistic: 358.743 on 2 and 177 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_walhus_time_unbal )
  Oneway (time) effect Random Effect Model 
     (Wallace-Hussain's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "time", 
      model = "random", random.method = "walhus")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 9666.19   98.32     1
  time             0.00    0.00     0
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
        0       0       0       0       0       0 
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.8494  -29.8087    5.3955   34.7586  368.5334 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -43.0915664   9.5781503 -4.4989 6.829e-06 ***
  value         0.1156300   0.0058506 19.7637 < 2.2e-16 ***
  capital       0.2310875   0.0255505  9.0443 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1754400
  R-Squared:      0.81216
  Adj. R-Squared: 0.81025
  Chisq: 847.453 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_swar_time_unbal   )
  Oneway (time) effect Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "time", 
      model = "random", random.method = "swar")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 9671.53   98.34     1
  time             0.00    0.00     0
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
        0       0       0       0       0       0 
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.8494  -29.8087    5.3955   34.7586  368.5334 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -43.0915664   9.5781503 -4.4989 6.829e-06 ***
  value         0.1156300   0.0058506 19.7637 < 2.2e-16 ***
  capital       0.2310875   0.0255505  9.0443 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1754400
  R-Squared:      0.81216
  Adj. R-Squared: 0.81025
  Chisq: 847.453 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_amemiya_time_unbal)
  Oneway (time) effect Random Effect Model 
     (Amemiya's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "time", 
      model = "random", random.method = "amemiya")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 9671.53   98.34     1
  time             0.00    0.00     0
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
        0       0       0       0       0       0 
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.8494  -29.8087    5.3955   34.7586  368.5334 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -43.0915664   9.5781503 -4.4989 6.829e-06 ***
  value         0.1156300   0.0058506 19.7637 < 2.2e-16 ***
  capital       0.2310875   0.0255505  9.0443 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1754400
  R-Squared:      0.81216
  Adj. R-Squared: 0.81025
  Chisq: 847.453 on 2 DF, p-value: < 2.22e-16
  > # summary(plm_grunfeld_re_nerlove_time_unbal) # not implemented
  > 
  > 
  > 
  > 
  > # Table 3.1 Grunfeld's Data. Two-way Error Component Results
  > #  RE estimators: SWAR and WALHUS yield negative estimates of
  > #  sigma_lambda^2 and these are set to zero in the table.
  > #
  > #           beta1     beta2   rho  sigma_me sigma_nu
  > #-------------------------------------------------
  > # [...]
  > 
  > #### twoways balanced
  > plm_grunfeld_pooled_tw     <- plm(inv ~ value + capital, data=Grunfeld, model="pooling", effect = "twoways")
  > plm_grunfeld_fe_tw         <- plm(inv ~ value + capital, data=Grunfeld, model="within",  effect = "twoways")
  > plm_grunfeld_re_walhus_tw  <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="walhus",  effect = "twoways")
  > plm_grunfeld_re_amemiya_tw <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="amemiya", effect = "twoways")
  > plm_grunfeld_re_swar_tw    <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="swar",    effect = "twoways")
  > plm_grunfeld_re_nerlove_tw <- plm(inv ~ value + capital, data=Grunfeld, model="random", random.method="nerlove", effect = "twoways")
  > 
  > summary(plm_grunfeld_pooled_tw    )
  Pooling Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", 
      model = "pooling")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.6757  -30.0137    5.3033   34.8293  369.4464 
  
  Coefficients:
                 Estimate  Std. Error t-value  Pr(>|t|)    
  (Intercept) -42.7143694   9.5116760 -4.4907 1.207e-05 ***
  value         0.1155622   0.0058357 19.8026 < 2.2e-16 ***
  capital       0.2306785   0.0254758  9.0548 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9359900
  Residual Sum of Squares: 1755900
  R-Squared:      0.81241
  Adj. R-Squared: 0.8105
  F-statistic: 426.576 on 2 and 197 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_fe_tw        )
  Twoways effects Within Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", 
      model = "within")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -162.6094  -19.4710   -1.2669   19.1277  211.8420 
  
  Coefficients:
          Estimate Std. Error t-value  Pr(>|t|)    
  value   0.117716   0.013751  8.5604 6.653e-15 ***
  capital 0.357916   0.022719 15.7540 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    1615600
  Residual Sum of Squares: 452150
  R-Squared:      0.72015
  Adj. R-Squared: 0.67047
  F-statistic: 217.442 on 2 and 169 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_walhus_tw )
  Twoways effects Random Effect Model 
     (Wallace-Hussain's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", 
      model = "random", random.method = "walhus")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 3188.06   56.46 0.359
  individual    5685.23   75.40 0.641
  time             0.00    0.00 0.000
  theta: 0.8349 (id) 0 (time) 2.776e-17 (total)
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -181.7595  -22.3727    5.9119   18.7001  254.1129 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.522213  25.012301 -2.2998  0.02146 *  
  value         0.109703   0.010147 10.8113  < 2e-16 ***
  capital       0.307286   0.017283 17.7795  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2438400
  Residual Sum of Squares: 559450
  R-Squared:      0.77057
  Adj. R-Squared: 0.76824
  Chisq: 661.637 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_amemiya_tw)
  Twoways effects Random Effect Model 
     (Amemiya's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", 
      model = "random", random.method = "amemiya")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 2644.13   51.42 0.256
  individual    7452.02   86.33 0.721
  time           243.78   15.61 0.024
  theta: 0.868 (id) 0.2787 (time) 0.2776 (total)
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -176.9062  -18.0431    3.2697   17.1719  234.1735 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -63.767791  29.851537 -2.1362  0.03267 *  
  value         0.111386   0.010909 10.2102  < 2e-16 ***
  capital       0.323321   0.018772 17.2232  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2066800
  Residual Sum of Squares: 518200
  R-Squared:      0.74927
  Adj. R-Squared: 0.74673
  Chisq: 588.717 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_swar_tw   )
  Twoways effects Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", 
      model = "random", random.method = "swar")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 2675.43   51.72 0.274
  individual    7095.25   84.23 0.726
  time             0.00    0.00 0.000
  theta: 0.864 (id) 0 (time) 0 (total)
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -177.1700  -19.7576    4.6048   19.4676  252.7596 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -57.865377  29.393359 -1.9687  0.04899 *  
  value         0.109790   0.010528 10.4285  < 2e-16 ***
  capital       0.308190   0.017171 17.9483  < 2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    2376000
  Residual Sum of Squares: 547910
  R-Squared:      0.7694
  Adj. R-Squared: 0.76706
  Chisq: 657.295 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_nerlove_tw)
  Twoways effects Random Effect Model 
     (Nerlove's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld, effect = "twoways", 
      model = "random", random.method = "nerlove")
  
  Balanced Panel: n = 10, T = 20, N = 200
  
  Effects:
                    var std.dev share
  idiosyncratic 2260.74   47.55 0.201
  individual    8426.92   91.80 0.751
  time           534.94   23.13 0.048
  theta: 0.885 (id) 0.455 (time) 0.4532 (total)
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -173.1203  -16.4742    2.0885   18.8439  221.8104 
  
  Coefficients:
                Estimate Std. Error z-value Pr(>|z|)    
  (Intercept) -68.304674  33.457520 -2.0415   0.0412 *  
  value         0.112729   0.011330  9.9499   <2e-16 ***
  capital       0.334494   0.019686 16.9917   <2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    1896600
  Residual Sum of Squares: 496930
  R-Squared:      0.73799
  Adj. R-Squared: 0.73533
  Chisq: 554.874 on 2 DF, p-value: < 2.22e-16
  > 
  > ##### twoways unbalanced
  > plm_grunfeld_pooled_tw_unbal     <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="pooling", effect = "twoways")
  > plm_grunfeld_fe_tw_unbal         <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="within",  effect = "twoways")
  > plm_grunfeld_re_walhus_tw_unbal  <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="walhus",  effect = "twoways")
  > plm_grunfeld_re_amemiya_tw_unbal <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="amemiya", effect = "twoways")
  > plm_grunfeld_re_swar_tw_unbal    <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="swar",    effect = "twoways")
  > ## not implemented:
  > # plm_grunfeld_re_nerlove_tw_unbal <- plm(inv ~ value + capital, data=Grunfeld_unbal, model="random", random.method="nerlove", effect = "twoways")
  > 
  > summary(plm_grunfeld_pooled_tw_unbal    )
  Pooling Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "twoways", 
      model = "pooling")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -291.8494  -29.8087    5.3955   34.7586  368.5334 
  
  Coefficients:
                 Estimate  Std. Error t-value  Pr(>|t|)    
  (Intercept) -43.0915664   9.5781503 -4.4989 1.169e-05 ***
  value         0.1156300   0.0058506 19.7637 < 2.2e-16 ***
  capital       0.2310875   0.0255505  9.0443 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1754400
  R-Squared:      0.81216
  Adj. R-Squared: 0.81025
  F-statistic: 423.727 on 2 and 196 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_fe_tw_unbal        )
  Twoways effects Within Model
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "twoways", 
      model = "within")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Residuals:
       Min.   1st Qu.    Median   3rd Qu.      Max. 
  -163.3268  -19.0378   -1.7054   20.7438  212.5877 
  
  Coefficients:
          Estimate Std. Error t-value  Pr(>|t|)    
  value   0.118504   0.013775  8.6029 5.299e-15 ***
  capital 0.361140   0.022951 15.7352 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    1597100
  Residual Sum of Squares: 449510
  R-Squared:      0.71855
  Adj. R-Squared: 0.66829
  F-statistic: 214.457 on 2 and 168 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_walhus_tw_unbal )
  Twoways effects Random Effect Model 
     (Wallace-Hussain's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "twoways", 
      model = "random", random.method = "walhus")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 3078.75   55.49 0.287
  individual    7655.76   87.50 0.713
  time             0.00    0.00 0.000
  theta:
                 Min.       1st Qu.        Median          Mean       3rd Qu.
  id     8.560314e-01  8.596040e-01  8.596040e-01  8.592629e-01  8.596040e-01
  time   0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
  total -5.551115e-17 -5.551115e-17 -5.551115e-17 -4.756106e-17 -5.551115e-17
                Max.
  id    8.596040e-01
  time  0.000000e+00
  total 2.775558e-17
  
  Residuals:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  -329.39  -41.02   10.57   -0.25   46.73  329.43 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -5.7828e+01  5.4187e-01 -106.72 < 2.2e-16 ***
  value        1.0978e-01  1.9828e-04  553.65 < 2.2e-16 ***
  capital      3.0806e-01  3.2541e-04  946.70 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1838200
  R-Squared:      0.80588
  Adj. R-Squared: 0.8039
  Chisq: 799.876 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_amemiya_tw_unbal)
  Twoways effects Random Effect Model 
     (Amemiya's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "twoways", 
      model = "random", random.method = "amemiya")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 2675.67   51.73 0.241
  individual    8088.44   89.94 0.729
  time           326.08   18.06 0.029
  theta:
             Min.   1st Qu.    Median      Mean   3rd Qu.      Max.
  id    0.8691846 0.8724423 0.8724423 0.8721313 0.8724423 0.8724423
  time  0.3094100 0.3286443 0.3286443 0.3277744 0.3286443 0.3286443
  total 0.3082868 0.3273981 0.3273981 0.3265245 0.3273981 0.3273981
  
  Residuals:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  -344.32  -44.34   14.98   -0.19   51.14  324.13 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -6.5371e+01  6.0239e-01 -108.52 < 2.2e-16 ***
  value        1.1185e-01  2.1633e-04  517.04 < 2.2e-16 ***
  capital      3.2691e-01  3.7420e-04  873.62 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1896700
  R-Squared:      0.80418
  Adj. R-Squared: 0.80218
  Chisq: 769.194 on 2 DF, p-value: < 2.22e-16
  > summary(plm_grunfeld_re_swar_tw_unbal   )
  Twoways effects Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = inv ~ value + capital, data = Grunfeld_unbal, effect = "twoways", 
      model = "random", random.method = "swar")
  
  Unbalanced Panel: n = 10, T = 19-20, N = 199
  
  Effects:
                    var std.dev share
  idiosyncratic 2675.67   51.73 0.273
  individual    7131.05   84.45 0.727
  time             0.00    0.00 0.000
  theta:
                 Min.      1st Qu.       Median         Mean      3rd Qu.
  id     8.608394e-01 8.642973e-01 8.642973e-01 8.639671e-01 8.642973e-01
  time   0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
  total -2.775558e-17 5.551115e-17 5.551115e-17 4.756106e-17 5.551115e-17
                Max.
  id    8.642973e-01
  time  0.000000e+00
  total 5.551115e-17
  
  Residuals:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  -329.50  -41.03   10.61   -0.25   46.75  329.39 
  
  Coefficients:
                 Estimate  Std. Error z-value  Pr(>|z|)    
  (Intercept) -5.7881e+01  5.5860e-01 -103.62 < 2.2e-16 ***
  value        1.0979e-01  1.9973e-04  549.70 < 2.2e-16 ***
  capital      3.0820e-01  3.2561e-04  946.53 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    9340000
  Residual Sum of Squares: 1838600
  R-Squared:      0.80587
  Adj. R-Squared: 0.80389
  Chisq: 799.693 on 2 DF, p-value: < 2.22e-16
  > # summary(plm_grunfeld_re_nerlove_tw_unbal) # not implemented
  > 
  > 
  > 
  > ### "amemiya" and "swar" have the same idiosyncratic variance (both based on the within variance)
  > # if (!isTRUE(all.equal(ercomp(plm_grunfeld_re_amemiya)[["sigma2"]][["idios"]], ercomp(plm_grunfeld_re_swar)[["sigma2"]][["idios"]])))
  > #   stop("idiosyncratic variance for 'amemiya' and 'swar' differ!")
  > # 
  > # if (!isTRUE(all.equal(ercomp(plm_grunfeld_re_amemiya_time)[["sigma2"]][["idios"]], ercomp(plm_grunfeld_re_swar_time)[["sigma2"]][["idios"]])))
  > #   stop("idiosyncratic variance for 'amemiya' and 'swar' differ!")
  > # 
  > # if (!isTRUE(all.equal(ercomp(plm_grunfeld_re_amemiya_unbal)[["sigma2"]][["idios"]], ercomp(plm_grunfeld_re_swar_unbal)[["sigma2"]][["idios"]])))
  > #   stop("idiosyncratic variance for 'amemiya' and 'swar' differ!")
  > # 
  > # if (!isTRUE(all.equal(ercomp(plm_grunfeld_re_amemiya_time_unbal)[["sigma2"]][["idios"]], ercomp(plm_grunfeld_re_swar_time_unbal)[["sigma2"]][["idios"]])))
  > #   stop("idiosyncratic variance for 'amemiya' and 'swar' differ!")
  > # 
  > # if (!isTRUE(all.equal(ercomp(plm_grunfeld_re_amemiya_tw)[["sigma2"]][["idios"]], ercomp(plm_grunfeld_re_swar_tw)[["sigma2"]][["idios"]])))
  > #   stop("idiosyncratic variance for 'amemiya' and 'swar' differ!")
  > # 
  > # if (!isTRUE(all.equal(ercomp(plm_grunfeld_re_amemiya_tw_unbal)[["sigma2"]][["idios"]], ercomp(plm_grunfeld_re_swar_tw_unbal)[["sigma2"]][["idios"]])))
  > #   stop("idiosyncratic variance for 'amemiya' and 'swar' differ!")
  > 
  > 
  > 
  > #### (2) ####
  > ####### replicate Stata's fixed effects estimator, R-squared, F statistic ###
  > ## http://www.stata.com/manuals/xtxtreg.pdf [example 2 on p. 14]
  > # library(plm)
  > # library(haven)
  > # nlswork <- read_dta("http://www.stata-press.com/data/r14/nlswork.dta") # large file
  > # nlswork$race <- factor(nlswork$race) # convert
  > # nlswork$race2 <- factor(ifelse(nlswork$race == 2, 1, 0)) # need this variable for example
  > # nlswork$grade <- as.numeric(nlswork$grade)
  > # pnlswork <- pdata.frame(nlswork, index=c("idcode", "year"), drop.index=FALSE)
  > # 
  > # form_nls_ex2 <- formula(ln_wage ~ grade + age + I(age^2) + ttl_exp + I(ttl_exp^2) + tenure + I(tenure^2) + race2 + not_smsa + south)
  > # 
  > # plm_fe_nlswork <- plm(form_nls_ex2, data = pnlswork, model = "within")
  > 
  > # Stata's results:
  > #
  > # R-sq:                                          
  > #   within  = 0.1727                               
  > #   between = 0.3505                               
  > #   overall = 0.262
  > 
  > # F(8,23386) = 610.12
  > # Prob > F = 0.0000
  > 
  > # ln_wage                       Coef.       Std. Err.
  > #-------------------------------------------------------
  > # grade                           0         (omitted)
  > # age                         .0359987      .0033864    
  > # c.age#c.age                -.000723       .0000533
  > # ttl_exp                     .0334668      .0029653    
  > # c.ttl_exp#c.ttl_exp         .0002163      .0001277    
  > # tenure                      .0357539      .0018487    
  > # c.tenure#c.tenure          -.0019701      .000125   
  > #   race
  > # black                           0         (omitted)
  > # not_smsa                   -.0890108      .0095316   
  > # south                      -.0606309      .0109319
  > # _cons                      1.03732        .0485546
  > 
  > # resambles Stata (ex. 2, p. 14)
  > # => coefficients, std.errors, R^2 (=R-sq within), F => correct
  > # (NB: Stata outputs an "artificial" constant for FE models, see below)
  > #summary(plm_fe_nlswork)
  > 
  > # Stata outputs a constant for the FE model which is computed as the weighted average of the individual constants
  > # see http://www.stata.com/support/faqs/statistics/intercept-in-fixed-effects-model/
  > # However, Stata also outputs std.err, t-test and p-value for the artificial constant
  > # gretl mimics Stata: see gretl user's guide example p. 160-161 (example 18.1)
  > # http://gretl.sourceforge.net/gretl-help/gretl-guide.pdf
  > # http://lists.wfu.edu/pipermail/gretl-devel/2013-May/004459.html
  > #within.intercept(plm_fe_nlswork)
  > #const_fe_Stata_gretl <- weighted.mean(fixef(plm_fe_nlswork) , as.numeric(table(index(plm_fe_nlswork)[[1]])))
  > 
  > # RE estimator
  > # note Stata 14 uses by default a different method compared to plm's Swamy-Arora variance component estimator
  > # This is why in comparison with web examples from Stata the random effects coefficients slightly differ
  > #plm_re_nlswork <- plm(form_nls_ex2, data = pnlswork, model = "random")
  > 
  > #### (3) ####
  > ## Test of unbalanced random effects estimator on Hedonic data of Harrison/Rubinfeld (1978)
  > 
  > ## NB: Baltagi's text book, table 9.1 uses the Stata results, the original paper Baltagi/Chang (1994) what EViews and plm yields
  > ##     However, the standard error of plm do not match exactly EViews and the paper. We don't know what exactly
  > ##     EViews or Baltagi/Chang (1994) did (the paper mentions "approximate" standard errors).
  > ##     A detailed explanation what EViews does is here: http://forums.eviews.com/viewtopic.php?f=4&t=18629#p59506
  > 
  > # scaling of variables in dataset Hedonic is a little bit different to Baltagi/Chang (1994) and Baltagi's text book, table 9.1
  > # see below for scaling as in Baltagi/Chang (1994)
  > data("Hedonic", package = "plm")
  > pHedonic <- pdata.frame(Hedonic, index = "townid")
  > form <- formula(mv ~ crim + zn + indus + chas + nox + rm + age + dis + rad + tax + ptratio + blacks + lstat)
  > summary(plm(form, data = pHedonic, model = "random"))
  Oneway (individual) effect Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = form, data = pHedonic, model = "random")
  
  Unbalanced Panel: n = 92, T = 1-30, N = 506
  
  Effects:
                    var std.dev share
  idiosyncratic 0.01696 0.13025 0.562
  individual    0.01324 0.11505 0.438
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.2505  0.5483  0.6284  0.6141  0.7147  0.7976 
  
  Residuals:
      Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  -0.62902 -0.06712 -0.00156 -0.00216  0.06858  0.54973 
  
  Coefficients:
                 Estimate  Std. Error  z-value  Pr(>|z|)    
  (Intercept)  9.6859e+00  1.9751e-01  49.0398 < 2.2e-16 ***
  crim        -7.4120e-03  1.0478e-03  -7.0738 1.508e-12 ***
  zn           7.8877e-05  6.5001e-04   0.1213 0.9034166    
  indus        1.5563e-03  4.0349e-03   0.3857 0.6997051    
  chasyes     -4.4247e-03  2.9212e-02  -0.1515 0.8796041    
  nox         -5.8425e-03  1.2452e-03  -4.6921 2.704e-06 ***
  rm           9.0552e-03  1.1886e-03   7.6182 2.573e-14 ***
  age         -8.5787e-04  4.6793e-04  -1.8333 0.0667541 .  
  dis         -1.4442e-01  4.4094e-02  -3.2753 0.0010557 ** 
  rad          9.5984e-02  2.6611e-02   3.6069 0.0003098 ***
  tax         -3.7740e-04  1.7693e-04  -2.1331 0.0329190 *  
  ptratio     -2.9476e-02  9.0698e-03  -3.2499 0.0011546 ** 
  blacks       5.6278e-01  1.0197e-01   5.5188 3.413e-08 ***
  lstat       -2.9107e-01  2.3927e-02 -12.1650 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    987.94
  Residual Sum of Squares: 8.9988
  R-Squared:      0.99091
  Adj. R-Squared: 0.99067
  Chisq: 53522.6 on 13 DF, p-value: < 2.22e-16
  > 
  > ## do (weired) scaling of variables as in Baltagi/Chang (1994)
  > Hedonic$mv2      <- Hedonic$mv
  > Hedonic$crim2    <- Hedonic$crim / 100
  > Hedonic$zn2      <- Hedonic$zn / 1000
  > Hedonic$indus2   <- Hedonic$indus / 100
  > Hedonic$chas2    <- (as.numeric(Hedonic$chas)-1) / 10
  > Hedonic$nox2     <- Hedonic$nox / 100
  > Hedonic$rm2      <- Hedonic$rm / 100
  > Hedonic$age2     <- Hedonic$age / 1000
  > Hedonic$dis2     <- Hedonic$dis / 10
  > Hedonic$rad2     <- Hedonic$rad / 10
  > Hedonic$tax2     <- Hedonic$tax / 1000
  > Hedonic$ptratio2 <- Hedonic$ptratio / 100
  > Hedonic$lstat2   <- Hedonic$lstat / 10
  > 
  > pHedonic2 <- pdata.frame(Hedonic, index = "townid")
  > form2 <- formula(mv2 ~ crim2 + zn2 + indus2 + chas2 + nox2 + rm2 + age2 + dis2 + rad2 + tax2 + ptratio2 + blacks + lstat2)
  > summary(plm(form2, data = pHedonic2, model = "random"))
  Oneway (individual) effect Random Effect Model 
     (Swamy-Arora's transformation)
  
  Call:
  plm(formula = form2, data = pHedonic2, model = "random")
  
  Unbalanced Panel: n = 92, T = 1-30, N = 506
  
  Effects:
                    var std.dev share
  idiosyncratic 0.01696 0.13025 0.562
  individual    0.01324 0.11505 0.438
  theta:
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.2505  0.5483  0.6284  0.6141  0.7147  0.7976 
  
  Residuals:
      Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  -0.62902 -0.06712 -0.00156 -0.00216  0.06858  0.54973 
  
  Coefficients:
               Estimate Std. Error  z-value  Pr(>|z|)    
  (Intercept)  9.685867   0.197510  49.0398 < 2.2e-16 ***
  crim2       -0.741197   0.104781  -7.0738 1.508e-12 ***
  zn2          0.078877   0.650012   0.1213 0.9034166    
  indus2       0.155634   0.403491   0.3857 0.6997051    
  chas2       -0.044247   0.292118  -0.1515 0.8796041    
  nox2        -0.584251   0.124518  -4.6921 2.704e-06 ***
  rm2          0.905517   0.118863   7.6182 2.573e-14 ***
  age2        -0.857873   0.467933  -1.8333 0.0667541 .  
  dis2        -1.444184   0.440937  -3.2753 0.0010557 ** 
  rad2         0.959839   0.266109   3.6069 0.0003098 ***
  tax2        -0.377396   0.176926  -2.1331 0.0329190 *  
  ptratio2    -2.947578   0.906984  -3.2499 0.0011546 ** 
  blacks       0.562775   0.101974   5.5188 3.413e-08 ***
  lstat2      -2.910749   0.239273 -12.1650 < 2.2e-16 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  Total Sum of Squares:    987.94
  Residual Sum of Squares: 8.9988
  R-Squared:      0.99091
  Adj. R-Squared: 0.99067
  Chisq: 53522.6 on 13 DF, p-value: < 2.22e-16
  > 
  > 
  > # pcce(., model = "mg") amd pmg(., model = "cmg") estimate  the same model but
  > # in a different way - coefficients need to match
  > data("Produc", package = "plm")
  > form <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
  > pccemgmod <- pcce(form, data = Produc, model="mg")
  > pmgccemgmod <- pmg(form, data = Produc, model="cmg")
  > common <- intersect(names(pccemgmod[["coefficients"]]), names(pmgccemgmod[["coefficients"]]))
  > coef_pccemgmod   <- round(pccemgmod[["coefficients"]][common],   digits = 7)
  > coef_pmgccemgmod <- round(pmgccemgmod[["coefficients"]][common], digits = 7)
  > stopifnot(all.equal(coef_pccemgmod, coef_pmgccemgmod))
  Error: coef_pccemgmod and coef_pmgccemgmod are not equal:
    Mean relative difference: 1.597787e-07
  Execution halted