An Application to HB Rao yu Model On sampel dataset

Load package and data

library(saeHB.panel)
data("dataPanel")

Fitting Model

area = max(dataPanel[,2])
period = max(dataPanel[,3])
vardir = dataPanel[,4]
result=Panel(ydi~xdi1+xdi2,area=area, period=period, vardir=vardir ,iter.mcmc = 10000,thin=5,burn.in = 1000,data=dataPanel)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 100
#>    Unobserved stochastic nodes: 125
#>    Total graph size: 1045
#> 
#> Initializing model
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 100
#>    Unobserved stochastic nodes: 125
#>    Total graph size: 1045
#> 
#> Initializing model
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 100
#>    Unobserved stochastic nodes: 125
#>    Total graph size: 1045
#> 
#> Initializing model

Extract mean estimation

Estimation

result$Est
#>               MEAN        SD      2.5%       25%       50%       75%     97.5%
#> mu[1,1]   9.723664 0.6112683  8.519237  9.321458  9.723963 10.121754 10.902824
#> mu[2,1]   5.824378 0.7370342  4.352147  5.332510  5.833372  6.321688  7.231439
#> mu[3,1]   6.815908 0.5821256  5.663756  6.429555  6.808731  7.203492  7.969172
#> mu[4,1]  10.590095 0.6510799  9.296393 10.160081 10.589323 11.036723 11.850398
#> mu[5,1]   8.780990 0.5957041  7.628728  8.382668  8.769358  9.177463  9.983150
#> mu[6,1]   7.312822 0.5848041  6.135273  6.924183  7.317597  7.691126  8.483604
#> mu[7,1]   7.004231 0.7310222  5.633671  6.516327  6.998994  7.485621  8.537911
#> mu[8,1]   9.819480 0.6238810  8.595401  9.403240  9.794675 10.223385 11.124157
#> mu[9,1]   5.325415 0.6251330  4.111398  4.903640  5.330906  5.745828  6.504141
#> mu[10,1]  6.207977 0.6245519  4.992967  5.791071  6.211634  6.615252  7.453498
#> mu[11,1]  4.807990 0.5662404  3.715806  4.430966  4.794851  5.184537  5.906351
#> mu[12,1]  7.222976 0.5720793  6.135496  6.844048  7.226307  7.604056  8.322878
#> mu[13,1]  8.389722 0.6869435  7.014833  7.915478  8.410808  8.833539  9.685506
#> mu[14,1]  7.676289 0.5121864  6.690655  7.333118  7.674745  8.016929  8.681777
#> mu[15,1]  7.830787 0.5526308  6.728377  7.451308  7.834586  8.210294  8.931682
#> mu[16,1]  4.132527 0.5732968  3.055176  3.744244  4.136387  4.517915  5.254847
#> mu[17,1]  4.783350 0.7071572  3.423340  4.318023  4.780401  5.258751  6.180894
#> mu[18,1]  4.983317 0.5872418  3.842927  4.601201  4.987284  5.379662  6.189906
#> mu[19,1]  8.043452 0.5801370  6.856964  7.651372  8.055795  8.434031  9.137956
#> mu[20,1] 10.205536 0.6143436  9.014525  9.795076 10.188993 10.609499 11.447757
#> mu[1,2]   7.660061 0.7072955  6.267338  7.184103  7.662266  8.172843  8.961283
#> mu[2,2]   5.270999 0.6320368  4.067395  4.835846  5.254451  5.690318  6.537684
#> mu[3,2]   6.367752 0.6173705  5.190114  5.955485  6.363856  6.796363  7.547035
#> mu[4,2]   5.555584 0.5851628  4.421839  5.162145  5.561468  5.952279  6.671918
#> mu[5,2]  11.344160 0.4968724 10.360852 11.014166 11.344639 11.687901 12.316508
#> mu[6,2]   6.871077 0.6717882  5.561198  6.421755  6.865768  7.334782  8.119361
#> mu[7,2]   4.933847 0.6781324  3.564545  4.477675  4.940009  5.390080  6.245080
#> mu[8,2]   6.708216 0.7331424  5.226005  6.206694  6.708365  7.204056  8.116983
#> mu[9,2]   7.148629 0.5993317  5.974890  6.754039  7.142702  7.550329  8.321716
#> mu[10,2]  9.007252 0.7450769  7.551385  8.502379  9.022620  9.492366 10.450616
#> mu[11,2]  8.350478 0.6097577  7.151381  7.940001  8.326217  8.740063  9.573839
#> mu[12,2]  6.217860 0.6295121  4.962143  5.805513  6.224244  6.648592  7.415252
#> mu[13,2]  8.675853 0.6024213  7.506726  8.271488  8.651330  9.079678  9.887152
#> mu[14,2]  7.657496 0.6006967  6.502124  7.267581  7.651874  8.082446  8.824177
#> mu[15,2] 10.024940 0.6142552  8.843214  9.609506 10.015115 10.441897 11.236585
#> mu[16,2]  8.069702 0.5355338  7.000386  7.711750  8.086954  8.423014  9.125184
#> mu[17,2] 10.043996 0.5815221  8.911889  9.645521 10.032941 10.428995 11.154816
#> mu[18,2]  7.760132 0.6009561  6.557454  7.373451  7.744159  8.148111  9.013164
#> mu[19,2]  8.868768 0.6398147  7.590060  8.417839  8.906214  9.307409 10.089767
#> mu[20,2]  8.518729 0.6042617  7.370842  8.099080  8.517670  8.949048  9.692913
#> mu[1,3]  10.444070 0.4742824  9.523596 10.132695 10.438038 10.773100 11.355856
#> mu[2,3]   8.322540 0.5672308  7.228911  7.939477  8.321173  8.705900  9.461820
#> mu[3,3]   7.311571 0.5240995  6.268318  6.963908  7.302629  7.667139  8.329109
#> mu[4,3]   5.692836 0.6710246  4.421067  5.234945  5.677704  6.138136  7.037556
#> mu[5,3]   8.763416 0.6596917  7.496006  8.341682  8.762801  9.197092 10.045593
#> mu[6,3]   8.311265 0.5876544  7.161635  7.899908  8.304205  8.698240  9.512510
#> mu[7,3]   4.903631 0.6507921  3.687597  4.464670  4.892417  5.331092  6.184750
#> mu[8,3]  10.255640 0.5914390  9.095465  9.863346 10.261791 10.665373 11.386051
#> mu[9,3]   9.680864 0.6401407  8.489026  9.244855  9.657616 10.105475 10.922580
#> mu[10,3]  8.942932 0.6795378  7.627600  8.488854  8.965792  9.372830 10.245604
#> mu[11,3]  8.052336 0.6255678  6.812950  7.628491  8.051892  8.463773  9.279332
#> mu[12,3]  8.163758 0.6532113  6.885346  7.713385  8.154918  8.577364  9.464104
#> mu[13,3]  8.797629 0.7065410  7.419285  8.323583  8.794629  9.267117 10.156398
#> mu[14,3]  8.782331 0.6801421  7.479690  8.319022  8.784433  9.249158 10.118945
#> mu[15,3]  8.401010 0.6516857  7.139610  7.974280  8.405712  8.843775  9.675377
#> mu[16,3]  3.856752 0.6211611  2.592554  3.440126  3.871200  4.281211  5.061365
#> mu[17,3]  9.603444 0.5780370  8.490815  9.208203  9.605191  9.998606 10.784178
#> mu[18,3]  5.853854 0.6666648  4.589160  5.406236  5.836070  6.307192  7.177898
#> mu[19,3]  8.118223 0.5004519  7.126442  7.782896  8.125901  8.431517  9.073440
#> mu[20,3]  5.548978 0.6928870  4.204999  5.101191  5.546985  6.015382  6.934608
#> mu[1,4]   6.307638 0.5502357  5.228121  5.960137  6.320300  6.681583  7.362888
#> mu[2,4]   5.055940 0.6379053  3.795108  4.608257  5.063022  5.502261  6.283973
#> mu[3,4]   7.855844 0.6424762  6.608786  7.407455  7.834220  8.294747  9.105642
#> mu[4,4]   7.520935 0.5777881  6.381165  7.135348  7.523011  7.909710  8.628249
#> mu[5,4]   8.350863 0.6759438  6.946480  7.934922  8.380970  8.797645  9.675952
#> mu[6,4]   7.349164 0.6613551  6.014976  6.916005  7.366083  7.801738  8.617050
#> mu[7,4]   8.646165 0.5884358  7.481880  8.270558  8.646824  9.045117  9.846381
#> mu[8,4]   6.652079 0.6244246  5.430617  6.244517  6.632527  7.066455  7.878876
#> mu[9,4]   4.428591 0.6582414  3.120819  4.010011  4.440374  4.885103  5.660897
#> mu[10,4]  7.614100 0.6202826  6.388716  7.189227  7.616787  8.040298  8.790105
#> mu[11,4]  6.163492 0.5788441  5.013363  5.762958  6.152919  6.574612  7.266919
#> mu[12,4]  7.466970 0.6256517  6.210090  7.041119  7.460352  7.892557  8.711986
#> mu[13,4]  9.535206 0.5588244  8.457552  9.160040  9.532458  9.920991 10.590782
#> mu[14,4]  8.296072 0.4980407  7.290190  7.977801  8.311928  8.636527  9.253296
#> mu[15,4]  9.953425 0.7164040  8.514811  9.461042  9.978649 10.422505 11.320593
#> mu[16,4]  2.983086 0.5534105  1.858102  2.621045  2.988797  3.369939  4.054142
#> mu[17,4]  6.276827 0.6669271  4.870442  5.832721  6.292868  6.709708  7.531141
#> mu[18,4]  3.735839 0.5543445  2.624819  3.381018  3.727663  4.106237  4.797388
#> mu[19,4]  8.001697 0.5707169  6.897731  7.620168  7.998497  8.376493  9.127311
#> mu[20,4]  6.775277 0.5784845  5.607494  6.391509  6.779883  7.167046  7.898787
#> mu[1,5]   8.062443 0.6646692  6.722568  7.593758  8.071152  8.511549  9.325938
#> mu[2,5]   8.019477 0.6296378  6.793029  7.592715  8.019078  8.440330  9.260784
#> mu[3,5]   3.860854 0.6040372  2.694874  3.458674  3.871058  4.273807  5.033185
#> mu[4,5]   7.476997 0.5854649  6.337232  7.086933  7.478811  7.851277  8.675719
#> mu[5,5]   8.347181 0.5646373  7.251462  7.960013  8.336706  8.722126  9.459833
#> mu[6,5]  10.946546 0.5741231  9.836332 10.569693 10.949200 11.322153 12.084922
#> mu[7,5]   8.143672 0.8088549  6.571693  7.591012  8.148061  8.674360  9.773569
#> mu[8,5]   8.207947 0.6879587  6.925124  7.737622  8.210001  8.675839  9.568076
#> mu[9,5]   4.865666 0.4983981  3.890788  4.539992  4.872970  5.197896  5.843914
#> mu[10,5]  7.350802 0.5874846  6.267151  6.941086  7.325019  7.742479  8.548045
#> mu[11,5]  5.414444 0.5632643  4.277490  5.047429  5.429458  5.786030  6.515971
#> mu[12,5]  9.428212 0.6449558  8.100790  8.997264  9.423168  9.865019 10.692593
#> mu[13,5] 11.172276 0.7588405  9.728960 10.656834 11.135891 11.691277 12.668190
#> mu[14,5] 10.102035 0.5607841  8.986322  9.710931 10.129960 10.457043 11.262044
#> mu[15,5]  7.580093 0.5311053  6.519942  7.211625  7.592544  7.945263  8.598978
#> mu[16,5]  6.364961 0.6518116  5.067106  5.937461  6.381132  6.792452  7.656423
#> mu[17,5]  7.706045 0.7202027  6.290485  7.231585  7.722190  8.162355  9.142800
#> mu[18,5]  7.453765 0.6567782  6.150417  7.002764  7.420774  7.892382  8.771227
#> mu[19,5]  9.610056 0.6000195  8.472619  9.212438  9.598813 10.020619 10.775081
#> mu[20,5]  8.968127 0.6431050  7.665416  8.562608  8.968379  9.384505 10.253525

Coefficient Estimation

result$coefficient
#>             Mean        SD       2.5%        25%        50%       75%     97.5%
#> b[0] -0.06784196 0.2875436 -0.6318668 -0.2635371 -0.0653275 0.1338212 0.4957891
#> b[1]  2.15907143 0.1646588  1.8409535  2.0429638  2.1587973 2.2701234 2.4844365
#> b[2]  2.26722215 0.1043367  2.0663969  2.1949523  2.2704637 2.3405602 2.4698349

Random effect variance estimation

result$refvar
#> NULL

Extract MSE

MSE_HB=result$Est$SD^2
summary(MSE_HB)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.2249  0.3345  0.3793  0.3871  0.4338  0.6542

Extract RSE

RSE_HB=sqrt(MSE_HB)/result$Est$MEAN*100
summary(RSE_HB)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   4.380   6.918   7.999   8.782  10.153  18.552

You can compare with direct estimator

y_dir=dataPanel[,1]
y_HB=result$Est$MEAN
y=as.data.frame(cbind(y_dir,y_HB))
summary(y)
#>      y_dir             y_HB       
#>  Min.   : 2.555   Min.   : 2.983  
#>  1st Qu.: 6.144   1st Qu.: 6.300  
#>  Median : 7.684   Median : 7.733  
#>  Mean   : 7.562   Mean   : 7.564  
#>  3rd Qu.: 8.822   3rd Qu.: 8.768  
#>  Max.   :12.835   Max.   :11.344
MSE_dir=dataPanel[,4]
MSE=as.data.frame(cbind(MSE_dir, MSE_HB))
summary(MSE)
#>     MSE_dir           MSE_HB      
#>  Min.   :0.3133   Min.   :0.2249  
#>  1st Qu.:0.4971   1st Qu.:0.3345  
#>  Median :0.6294   Median :0.3793  
#>  Mean   :0.6800   Mean   :0.3871  
#>  3rd Qu.:0.7749   3rd Qu.:0.4338  
#>  Max.   :1.6929   Max.   :0.6542
RSE_dir=sqrt(MSE_dir)/y_dir*100
RSE=as.data.frame(cbind(MSE_dir, MSE_HB))
summary(RSE)
#>     MSE_dir           MSE_HB      
#>  Min.   :0.3133   Min.   :0.2249  
#>  1st Qu.:0.4971   1st Qu.:0.3345  
#>  Median :0.6294   Median :0.3793  
#>  Mean   :0.6800   Mean   :0.3871  
#>  3rd Qu.:0.7749   3rd Qu.:0.4338  
#>  Max.   :1.6929   Max.   :0.6542