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%
#> 1    9.735949 0.6121378  8.567735  9.317395  9.737974 10.145544 10.994328
#> 2    7.659038 0.7044743  6.248753  7.182316  7.690047  8.142173  8.960447
#> 3   10.453702 0.4811839  9.522878 10.140783 10.454707 10.768473 11.390893
#> 4    6.297277 0.5450886  5.252422  5.916801  6.288940  6.683777  7.371260
#> 5    8.049112 0.6659218  6.706812  7.599489  8.058002  8.501883  9.344586
#> 6    5.766448 0.7497661  4.223969  5.260277  5.790315  6.260757  7.238622
#> 7    5.198601 0.6505446  3.924509  4.771667  5.198760  5.613655  6.509753
#> 8    8.289370 0.5662593  7.145112  7.907951  8.311635  8.673833  9.413260
#> 9    5.041052 0.6272359  3.807721  4.617709  5.044117  5.472141  6.217980
#> 10   8.025084 0.6337914  6.793501  7.587574  8.040486  8.445983  9.225125
#> 11   6.836335 0.5729557  5.687766  6.451239  6.838707  7.219083  7.953967
#> 12   6.367160 0.6042771  5.171119  5.972091  6.369304  6.781055  7.548945
#> 13   7.321336 0.5351143  6.292801  6.953695  7.337132  7.688628  8.340143
#> 14   7.904344 0.6468338  6.650875  7.478424  7.909097  8.327142  9.199033
#> 15   3.882464 0.5797566  2.755131  3.489755  3.878520  4.288515  4.996382
#> 16  10.612400 0.6364409  9.365214 10.188094 10.612055 11.042238 11.865563
#> 17   5.529372 0.5929085  4.435540  5.126991  5.525258  5.925288  6.722707
#> 18   5.711196 0.6550802  4.457098  5.287509  5.691249  6.159764  7.041247
#> 19   7.537422 0.5920514  6.358459  7.134664  7.541426  7.944604  8.661639
#> 20   7.481153 0.5970112  6.338063  7.072598  7.458780  7.882106  8.675665
#> 21   8.782549 0.6049014  7.633092  8.376638  8.774738  9.175899  9.979196
#> 22  11.348342 0.5012512 10.401823 11.010482 11.366300 11.679545 12.307202
#> 23   8.700078 0.6551946  7.437538  8.242929  8.690697  9.133692  9.975174
#> 24   8.352716 0.6680579  7.015852  7.917489  8.378008  8.806466  9.598347
#> 25   8.311734 0.5693600  7.248545  7.926767  8.328394  8.704065  9.393986
#> 26   7.298087 0.5866371  6.199235  6.895541  7.308114  7.688962  8.409395
#> 27   6.858620 0.6732228  5.520112  6.398891  6.872498  7.309536  8.182303
#> 28   8.344350 0.5671279  7.245632  7.952137  8.340127  8.715310  9.464526
#> 29   7.368477 0.6918846  6.018667  6.902439  7.393045  7.823638  8.726341
#> 30  10.938084 0.5976249  9.789713 10.533218 10.941321 11.342965 12.083861
#> 31   6.973436 0.7437112  5.549925  6.457724  6.967912  7.470393  8.405680
#> 32   4.903108 0.6929095  3.558959  4.439249  4.891664  5.357967  6.270334
#> 33   4.877547 0.6548079  3.578263  4.423984  4.882281  5.321828  6.140086
#> 34   8.658485 0.5687610  7.525848  8.283215  8.657967  9.040515  9.718471
#> 35   8.134487 0.7764808  6.663605  7.612095  8.143926  8.669493  9.628789
#> 36   9.783047 0.6417051  8.506458  9.346193  9.776710 10.222915 11.038353
#> 37   6.657348 0.7388632  5.238824  6.132719  6.633701  7.151968  8.104646
#> 38  10.245847 0.5910248  9.058181  9.842114 10.253098 10.641357 11.363890
#> 39   6.650903 0.6365261  5.418151  6.214801  6.634641  7.097875  7.856829
#> 40   8.194216 0.6814879  6.866800  7.725982  8.199317  8.636156  9.546680
#> 41   5.325361 0.6263146  4.004998  4.905226  5.341808  5.748813  6.571450
#> 42   7.162074 0.6240977  5.968728  6.746705  7.148308  7.581462  8.397846
#> 43   9.670416 0.6181281  8.488326  9.248174  9.660570 10.101743 10.829171
#> 44   4.456775 0.6413931  3.219746  4.027285  4.450801  4.912894  5.670077
#> 45   4.897188 0.4996369  3.943678  4.549180  4.898268  5.239143  5.901005
#> 46   6.202616 0.6509340  4.915031  5.752480  6.193635  6.630903  7.458573
#> 47   9.019272 0.7760212  7.470275  8.519884  9.036367  9.537772 10.513910
#> 48   8.965524 0.6912567  7.669118  8.502673  8.947947  9.435706 10.297405
#> 49   7.600447 0.6114461  6.421201  7.179628  7.600246  8.018466  8.820040
#> 50   7.356035 0.5793126  6.232122  6.951674  7.362215  7.742041  8.536628
#> 51   4.791197 0.5599882  3.668142  4.403974  4.773631  5.177508  5.919847
#> 52   8.323706 0.5935887  7.155002  7.936149  8.340430  8.711490  9.534025
#> 53   8.042837 0.6299469  6.811619  7.621292  8.057902  8.473784  9.262759
#> 54   6.121236 0.5492669  5.094068  5.720720  6.121078  6.484423  7.194599
#> 55   5.409486 0.5460336  4.381885  5.036666  5.403238  5.790154  6.473381
#> 56   7.228431 0.5718314  6.140890  6.842884  7.215396  7.610135  8.333789
#> 57   6.163553 0.6184403  4.999050  5.764833  6.139750  6.581747  7.356166
#> 58   8.171180 0.6691121  6.780232  7.724375  8.173173  8.631082  9.445246
#> 59   7.414350 0.6190073  6.192859  7.009204  7.418229  7.826181  8.595362
#> 60   9.454056 0.6290654  8.205452  9.025744  9.481282  9.886793 10.665682
#> 61   8.355348 0.6888520  6.977730  7.912315  8.354487  8.831335  9.682746
#> 62   8.662812 0.5967155  7.459707  8.272564  8.668659  9.060090  9.823466
#> 63   8.780451 0.7300686  7.316782  8.328851  8.774338  9.257016 10.161279
#> 64   9.539040 0.5585970  8.516799  9.163489  9.539765  9.915545 10.627114
#> 65  11.189206 0.7745236  9.641325 10.657559 11.168768 11.731545 12.737155
#> 66   7.634514 0.5157630  6.629451  7.283474  7.648590  7.967917  8.645451
#> 67   7.625944 0.6135744  6.465175  7.214532  7.635558  8.025929  8.877513
#> 68   8.777241 0.6800049  7.483548  8.305327  8.759944  9.243822 10.123432
#> 69   8.286562 0.4680264  7.316635  7.995572  8.285981  8.585894  9.211598
#> 70  10.074608 0.5651047  8.931933  9.709290 10.096195 10.449529 11.132893
#> 71   7.871299 0.5651614  6.748434  7.507661  7.878314  8.246035  8.981074
#> 72  10.024884 0.6219466  8.818762  9.581831 10.024654 10.449521 11.206561
#> 73   8.403710 0.6288665  7.208001  7.982019  8.390669  8.817939  9.706382
#> 74   9.971874 0.6954261  8.698280  9.497963  9.966099 10.444405 11.348806
#> 75   7.588726 0.5444926  6.541949  7.217258  7.584306  7.948679  8.647397
#> 76   4.106199 0.5695674  2.972178  3.719571  4.120510  4.482569  5.192925
#> 77   8.049372 0.5265914  7.010626  7.697080  8.041270  8.384769  9.092358
#> 78   3.832853 0.6176809  2.585330  3.400187  3.830435  4.233590  5.067853
#> 79   2.981198 0.5632213  1.833809  2.621826  2.997800  3.351580  4.059498
#> 80   6.343089 0.6720520  5.014648  5.890564  6.344433  6.790086  7.674171
#> 81   4.798933 0.6864811  3.477283  4.351462  4.782995  5.245087  6.150123
#> 82  10.036699 0.5832795  8.970668  9.653057 10.026594 10.433085 11.201843
#> 83   9.626379 0.5604178  8.473652  9.261895  9.639458 10.001778 10.692274
#> 84   6.255403 0.6488186  4.886265  5.850816  6.268610  6.678049  7.498141
#> 85   7.701270 0.7224672  6.288136  7.217773  7.703252  8.204897  9.070996
#> 86   4.969774 0.6052871  3.734310  4.580730  4.970488  5.373129  6.158406
#> 87   7.747988 0.5889062  6.604826  7.342356  7.730743  8.144714  8.907811
#> 88   5.870017 0.6465025  4.598935  5.434562  5.882998  6.316882  7.120723
#> 89   3.694486 0.5604431  2.596343  3.324021  3.694337  4.093418  4.752998
#> 90   7.434006 0.6494390  6.154185  7.008632  7.433452  7.857234  8.737611
#> 91   8.057735 0.5884660  6.894449  7.662945  8.062980  8.462046  9.177387
#> 92   8.889384 0.6547184  7.612325  8.447714  8.881262  9.334176 10.177310
#> 93   8.123292 0.4892343  7.203380  7.773962  8.111529  8.459402  9.093083
#> 94   7.988167 0.5763062  6.893634  7.599854  8.004051  8.370387  9.134768
#> 95   9.627186 0.6071962  8.411301  9.214983  9.625628 10.049837 10.768049
#> 96  10.169493 0.6387945  8.919428  9.737970 10.164583 10.587973 11.440235
#> 97   8.515764 0.6056714  7.350825  8.092639  8.516128  8.928916  9.665140
#> 98   5.523847 0.6828150  4.165543  5.083356  5.527076  5.976183  6.826558
#> 99   6.788477 0.5945450  5.598174  6.385088  6.804051  7.202265  7.894870
#> 100  8.953666 0.6516479  7.722518  8.510994  8.934912  9.388486 10.249274

Coefficient Estimation

result$coefficient
#>            Mean        SD       2.5%        25%        50%          75%
#> b[0] -0.1863384 0.2747091 -0.7213781 -0.3742546 -0.1952395 0.0004129886
#> b[1]  2.2136857 0.1710081  1.8604432  2.1043023  2.2141018 2.3343981014
#> b[2]  2.2783006 0.1004344  2.0905277  2.2075792  2.2761226 2.3448286080
#>          97.5%
#> b[0] 0.3496634
#> b[1] 2.5270772
#> b[2] 2.4789208

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.2190  0.3280  0.3818  0.3877  0.4289  0.6029

Extract RSE

RSE_HB=sqrt(MSE_HB)/result$Est$MEAN*100
summary(RSE_HB)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   4.417   6.888   8.042   8.794  10.121  18.892

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.981  
#>  1st Qu.: 6.144   1st Qu.: 6.287  
#>  Median : 7.684   Median : 7.725  
#>  Mean   : 7.562   Mean   : 7.557  
#>  3rd Qu.: 8.822   3rd Qu.: 8.719  
#>  Max.   :12.835   Max.   :11.348
MSE_dir=dataPanel[,4]
MSE=as.data.frame(cbind(MSE_dir, MSE_HB))
summary(MSE)
#>     MSE_dir           MSE_HB      
#>  Min.   :0.3133   Min.   :0.2190  
#>  1st Qu.:0.4971   1st Qu.:0.3280  
#>  Median :0.6294   Median :0.3818  
#>  Mean   :0.6800   Mean   :0.3877  
#>  3rd Qu.:0.7749   3rd Qu.:0.4289  
#>  Max.   :1.6929   Max.   :0.6029
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.2190  
#>  1st Qu.:0.4971   1st Qu.:0.3280  
#>  Median :0.6294   Median :0.3818  
#>  Mean   :0.6800   Mean   :0.3877  
#>  3rd Qu.:0.7749   3rd Qu.:0.4289  
#>  Max.   :1.6929   Max.   :0.6029