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.729058 0.6114056  8.531036  9.314558  9.719142 10.143217 10.911875
#> 2    7.637551 0.7033637  6.247115  7.172881  7.640769  8.107864  8.995988
#> 3   10.455365 0.4859571  9.537461 10.139173 10.446199 10.772226 11.447931
#> 4    6.298834 0.5386124  5.220279  5.937463  6.299821  6.649706  7.327139
#> 5    8.049336 0.6726068  6.759776  7.598334  8.056419  8.497693  9.412931
#> 6    5.795887 0.7149365  4.364910  5.321263  5.806706  6.286885  7.132234
#> 7    5.208649 0.6317565  3.991177  4.778986  5.228044  5.629600  6.428860
#> 8    8.293780 0.5778582  7.134798  7.909767  8.292052  8.704999  9.436595
#> 9    5.062252 0.6360209  3.821837  4.645109  5.050584  5.485616  6.336953
#> 10   8.029235 0.6314544  6.759409  7.611988  8.037450  8.456014  9.264910
#> 11   6.827151 0.5652709  5.709357  6.437832  6.815239  7.216166  7.944674
#> 12   6.357800 0.6313178  5.156265  5.921555  6.336196  6.784238  7.663001
#> 13   7.301850 0.5181577  6.287584  6.959778  7.304506  7.648555  8.315500
#> 14   7.872749 0.6433311  6.595653  7.418806  7.890671  8.306747  9.104275
#> 15   3.897739 0.6070125  2.683276  3.479366  3.902336  4.299767  5.106832
#> 16  10.595999 0.6596795  9.300842 10.147639 10.594284 11.031304 11.884400
#> 17   5.581122 0.5952727  4.400332  5.189615  5.579411  5.996792  6.749726
#> 18   5.692645 0.6568606  4.408223  5.257774  5.701258  6.138027  6.931305
#> 19   7.526094 0.5697831  6.438766  7.129929  7.532462  7.912824  8.629818
#> 20   7.477874 0.6101073  6.256601  7.058771  7.495665  7.889267  8.625569
#> 21   8.795382 0.6000389  7.618898  8.384407  8.793946  9.178540 10.009862
#> 22  11.356946 0.5008530 10.368913 11.025127 11.355120 11.698130 12.315543
#> 23   8.739673 0.6507154  7.412030  8.303584  8.730259  9.181637 10.021252
#> 24   8.350138 0.6728528  7.080686  7.884471  8.344805  8.809109  9.626758
#> 25   8.339546 0.5634227  7.249877  7.946801  8.329871  8.713305  9.477615
#> 26   7.292522 0.5779697  6.199997  6.909968  7.297060  7.666404  8.464075
#> 27   6.855590 0.6886265  5.479066  6.390471  6.876574  7.326716  8.224422
#> 28   8.317534 0.5814971  7.212940  7.930915  8.310614  8.713182  9.423665
#> 29   7.355399 0.6703312  6.036212  6.889120  7.348869  7.817940  8.666096
#> 30  10.959436 0.6208676  9.784598 10.539424 10.944442 11.389173 12.215221
#> 31   7.012414 0.7390908  5.633629  6.499159  7.014477  7.515976  8.443950
#> 32   4.917994 0.6779069  3.578273  4.470206  4.920222  5.386182  6.205153
#> 33   4.878854 0.6525649  3.568818  4.450088  4.886387  5.317124  6.139775
#> 34   8.660341 0.5880820  7.444910  8.279526  8.665161  9.044696  9.802020
#> 35   8.177056 0.7687322  6.665638  7.649037  8.189327  8.672626  9.701453
#> 36   9.783920 0.6371042  8.531829  9.364661  9.785403 10.195268 11.043819
#> 37   6.706512 0.7361648  5.221441  6.216630  6.726541  7.184550  8.135359
#> 38  10.261324 0.5976904  9.113953  9.875179 10.248372 10.659542 11.428450
#> 39   6.636538 0.6302316  5.417598  6.216839  6.637857  7.052802  7.884501
#> 40   8.178334 0.7029107  6.873611  7.719081  8.166865  8.633516  9.555902
#> 41   5.328177 0.6297775  4.097888  4.892005  5.339787  5.769157  6.507432
#> 42   7.162783 0.6348449  5.909428  6.754814  7.154516  7.563057  8.476045
#> 43   9.692305 0.6236799  8.484397  9.287436  9.692504 10.098156 10.917039
#> 44   4.462161 0.6536702  3.156662  4.031141  4.456334  4.898029  5.705477
#> 45   4.872848 0.4962434  3.889717  4.545607  4.874763  5.205069  5.781760
#> 46   6.170550 0.6650329  4.844828  5.722766  6.182653  6.612150  7.495553
#> 47   9.003000 0.7489212  7.493416  8.528217  9.024268  9.500493 10.426859
#> 48   8.963493 0.6671652  7.689382  8.539795  8.972655  9.403165 10.261875
#> 49   7.600890 0.6182953  6.426152  7.167090  7.594704  8.029175  8.811629
#> 50   7.339513 0.5733271  6.248401  6.955187  7.327022  7.735296  8.457414
#> 51   4.791703 0.5637845  3.653899  4.416346  4.783060  5.182539  5.891464
#> 52   8.348277 0.5936749  7.182684  7.941745  8.351231  8.739877  9.564472
#> 53   8.025939 0.6225233  6.786728  7.598371  8.024482  8.443672  9.197164
#> 54   6.121134 0.5815239  5.016911  5.717171  6.116189  6.504720  7.260188
#> 55   5.415497 0.5605139  4.377519  5.023878  5.409028  5.788081  6.531741
#> 56   7.229469 0.5722560  6.115649  6.856283  7.240658  7.612548  8.315721
#> 57   6.242775 0.6119410  5.034868  5.848955  6.247141  6.639015  7.412419
#> 58   8.179725 0.6880032  6.780096  7.733167  8.182655  8.662847  9.494218
#> 59   7.462287 0.6218526  6.223048  7.053707  7.461144  7.858558  8.733763
#> 60   9.456768 0.6366866  8.249593  9.019027  9.438886  9.891728 10.723278
#> 61   8.369522 0.6577164  7.058995  7.926987  8.380375  8.821099  9.621627
#> 62   8.655330 0.6135143  7.457067  8.247540  8.652927  9.079965  9.839451
#> 63   8.764540 0.7232598  7.257920  8.303850  8.780158  9.258085 10.239928
#> 64   9.561401 0.5511946  8.525302  9.182239  9.550362  9.911422 10.699253
#> 65  11.185453 0.7573143  9.714391 10.676112 11.190929 11.662906 12.701068
#> 66   7.670242 0.5069790  6.663457  7.320558  7.684585  8.003881  8.688948
#> 67   7.652621 0.6041439  6.471197  7.251296  7.652132  8.054697  8.832907
#> 68   8.749848 0.6820246  7.388996  8.285806  8.758262  9.202166 10.061227
#> 69   8.288418 0.4931374  7.320611  7.954427  8.292042  8.627991  9.250329
#> 70  10.083759 0.5611463  8.988781  9.683454 10.091830 10.460729 11.206131
#> 71   7.871688 0.5637120  6.741349  7.497396  7.867217  8.258911  8.958029
#> 72  10.010292 0.6069960  8.854391  9.603905 10.002886 10.404902 11.199252
#> 73   8.420923 0.6599032  7.111640  7.996054  8.418035  8.858036  9.717069
#> 74   9.950874 0.7350394  8.521350  9.434656  9.945622 10.451344 11.361822
#> 75   7.612475 0.5456563  6.558377  7.234412  7.600326  7.977831  8.699425
#> 76   4.099582 0.5695901  2.973675  3.739162  4.085651  4.478941  5.220073
#> 77   8.040602 0.5387310  6.984334  7.689305  8.041206  8.395337  9.081808
#> 78   3.830277 0.6238402  2.585890  3.411503  3.821982  4.259375  5.023936
#> 79   2.966816 0.5653595  1.835597  2.570284  2.980698  3.347886  4.071980
#> 80   6.365176 0.6763843  5.084032  5.890021  6.364436  6.817452  7.719133
#> 81   4.781555 0.6685439  3.527342  4.321664  4.773691  5.240043  6.089580
#> 82  10.025552 0.5778531  8.929844  9.636997 10.023724 10.410815 11.175993
#> 83   9.616768 0.5768817  8.514537  9.212375  9.600783 10.020911 10.782384
#> 84   6.253615 0.6455358  4.978226  5.814518  6.244513  6.704621  7.489071
#> 85   7.691198 0.7224487  6.226618  7.194109  7.709509  8.184169  9.059585
#> 86   4.951297 0.6049959  3.785663  4.539715  4.934166  5.356770  6.184493
#> 87   7.747534 0.5942290  6.567101  7.355552  7.746374  8.146761  8.883089
#> 88   5.887722 0.6818483  4.570396  5.443491  5.882646  6.325509  7.238036
#> 89   3.721897 0.5543037  2.658270  3.343615  3.722316  4.106644  4.768516
#> 90   7.445083 0.6541544  6.211653  7.005363  7.449274  7.856331  8.735205
#> 91   8.077651 0.5706843  6.983249  7.673948  8.101157  8.474288  9.164283
#> 92   8.932607 0.6471708  7.630396  8.495263  8.946868  9.378330 10.175612
#> 93   8.101259 0.4781179  7.217501  7.779717  8.095706  8.428612  9.006581
#> 94   8.019577 0.5712076  6.912692  7.636875  8.013507  8.403460  9.168116
#> 95   9.631780 0.5914277  8.471072  9.228292  9.625974 10.017343 10.832219
#> 96  10.192834 0.6392293  8.971333  9.755532 10.184048 10.616498 11.488037
#> 97   8.512694 0.6015387  7.321881  8.118084  8.514902  8.904251  9.697202
#> 98   5.548493 0.6715408  4.243506  5.106066  5.544492  6.000781  6.848901
#> 99   6.790219 0.6049122  5.608440  6.363732  6.781424  7.216462  7.982673
#> 100  8.966361 0.6531061  7.678059  8.509832  8.969978  9.391899 10.281115

Coefficient Estimation

result$coefficient
#>            Mean        SD       2.5%        25%        50%        75%     97.5%
#> b[0] -0.1270186 0.2833758 -0.6705518 -0.3199989 -0.1306129 0.06098509 0.4364159
#> b[1]  2.1822239 0.1678818  1.8566030  2.0697702  2.1786924 2.29503597 2.5189655
#> b[2]  2.2685311 0.1008219  2.0731030  2.1998648  2.2661413 2.33789813 2.4657860

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.2286  0.3318  0.3861  0.3886  0.4353  0.5909

Extract RSE

RSE_HB=sqrt(MSE_HB)/result$Est$MEAN*100
summary(RSE_HB)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   4.410   6.985   7.992   8.802  10.219  19.056

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.967  
#>  1st Qu.: 6.144   1st Qu.: 6.288  
#>  Median : 7.684   Median : 7.719  
#>  Mean   : 7.562   Mean   : 7.562  
#>  3rd Qu.: 8.822   3rd Qu.: 8.742  
#>  Max.   :12.835   Max.   :11.357
MSE_dir=dataPanel[,4]
MSE=as.data.frame(cbind(MSE_dir, MSE_HB))
summary(MSE)
#>     MSE_dir           MSE_HB      
#>  Min.   :0.3133   Min.   :0.2286  
#>  1st Qu.:0.4971   1st Qu.:0.3318  
#>  Median :0.6294   Median :0.3861  
#>  Mean   :0.6800   Mean   :0.3886  
#>  3rd Qu.:0.7749   3rd Qu.:0.4353  
#>  Max.   :1.6929   Max.   :0.5909
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.2286  
#>  1st Qu.:0.4971   1st Qu.:0.3318  
#>  Median :0.6294   Median :0.3861  
#>  Mean   :0.6800   Mean   :0.3886  
#>  3rd Qu.:0.7749   3rd Qu.:0.4353  
#>  Max.   :1.6929   Max.   :0.5909