An Aplication to SAE HB ME under Beta Distribution On Sample Data

case 1 : Auxiliary variables only contains variable with error in aux variable

Load Package and Load Data Set

library(saeHB.ME.beta)
data("dataHBMEbeta")

Fitting HB Model

example <- meHBbeta(Y~x1+x2, var.x = c("v.x1","v.x2"),
                   iter.update = 3, iter.mcmc = 10000,
                   thin = 3, burn.in = 1000, data = dataHBMEbeta)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 30
#>    Unobserved stochastic nodes: 126
#>    Total graph size: 623
#> 
#> Initializing model
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 30
#>    Unobserved stochastic nodes: 126
#>    Total graph size: 623
#> 
#> Initializing model
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 30
#>    Unobserved stochastic nodes: 126
#>    Total graph size: 623
#> 
#> Initializing model

Ekstract Mean Estimation

Small Area Mean Estimation

example$Est
#>             mean         sd      2.5%       25%       50%       75%     97.5%
#> mu[1]  0.8968983 0.07083178 0.7181748 0.8646669 0.9145680 0.9469303 0.9816643
#> mu[2]  0.7788631 0.13390728 0.4551356 0.7056284 0.8039745 0.8792847 0.9629878
#> mu[3]  0.9304646 0.05610690 0.7714164 0.9095143 0.9461797 0.9686061 0.9895881
#> mu[4]  0.9114493 0.06869810 0.7260876 0.8832259 0.9303235 0.9593671 0.9881202
#> mu[5]  0.9142426 0.06405652 0.7472540 0.8886668 0.9314247 0.9587908 0.9879760
#> mu[6]  0.8492971 0.10462327 0.5875980 0.7974436 0.8729467 0.9267935 0.9799992
#> mu[7]  0.5684939 0.21442122 0.1574116 0.4051423 0.5811876 0.7416130 0.9212736
#> mu[8]  0.9428601 0.04810042 0.8139343 0.9268279 0.9556760 0.9745016 0.9920714
#> mu[9]  0.8633030 0.10049482 0.5987058 0.8169968 0.8879464 0.9352222 0.9839084
#> mu[10] 0.9338775 0.05479029 0.7963396 0.9142793 0.9481405 0.9694260 0.9910250
#> mu[11] 0.9463897 0.04728466 0.8111769 0.9305909 0.9591692 0.9783055 0.9938036
#> mu[12] 0.8172012 0.11354657 0.5358640 0.7568563 0.8419972 0.9003994 0.9675736
#> mu[13] 0.7836520 0.13821751 0.4533939 0.7081686 0.8124612 0.8896763 0.9673886
#> mu[14] 0.8979550 0.07501702 0.7005640 0.8640868 0.9180239 0.9521916 0.9853310
#> mu[15] 0.9404910 0.04607794 0.8232995 0.9229388 0.9519206 0.9720697 0.9914247
#> mu[16] 0.8756889 0.08389377 0.6533207 0.8380056 0.8950224 0.9351953 0.9789984
#> mu[17] 0.6714062 0.17811372 0.2909978 0.5476195 0.6964938 0.8136202 0.9383777
#> mu[18] 0.9502983 0.04676509 0.8235835 0.9369087 0.9639910 0.9796402 0.9935434
#> mu[19] 0.9185019 0.05903838 0.7666068 0.8947431 0.9326817 0.9588578 0.9860851
#> mu[20] 0.9533001 0.03955127 0.8429337 0.9391167 0.9648569 0.9803337 0.9942951
#> mu[21] 0.9346557 0.06043256 0.7725473 0.9158460 0.9520633 0.9743547 0.9931923
#> mu[22] 0.8471069 0.10485137 0.5804646 0.7992597 0.8706762 0.9234261 0.9768591
#> mu[23] 0.9045317 0.08035997 0.6853718 0.8763166 0.9274882 0.9596443 0.9891973
#> mu[24] 0.7775620 0.12338203 0.4866764 0.7056298 0.7983863 0.8715648 0.9531180
#> mu[25] 0.8807347 0.07985252 0.6760926 0.8430087 0.9002047 0.9376184 0.9790901
#> mu[26] 0.8502276 0.09442800 0.6118425 0.8030505 0.8718848 0.9198340 0.9707970
#> mu[27] 0.8078351 0.14707976 0.4330983 0.7332433 0.8496306 0.9208751 0.9801190
#> mu[28] 0.9550847 0.04504043 0.8375084 0.9421792 0.9686394 0.9832529 0.9954069
#> mu[29] 0.8024078 0.12234112 0.5079886 0.7359885 0.8263864 0.8953287 0.9660237
#> mu[30] 0.8802764 0.11246770 0.5593900 0.8397359 0.9147428 0.9574246 0.9921282

Coefficient Estimation

example$coefficient
#>           Mean        SD       2.5%       25%       50%       75%     97.5%
#> b[0] 1.1167942 0.3235579  0.4809973 0.9073969 1.1110835 1.3391399 1.7368090
#> b[1] 0.2917350 0.2689136 -0.2218466 0.1059175 0.2926470 0.4723416 0.8261738
#> b[2] 0.3543135 0.1094443  0.1432267 0.2777059 0.3561431 0.4279583 0.5675754

Random Effect Variance Estimation

example$refvar
#> [1] 0.5666313

Extract MSE

MSE_HBMEbeta=example$Est$sd^2

Extract RSE

RSE_HBMEbeta=sqrt(MSE_HBMEbeta)/example$Est$mean*100

You can compare with Direct Estimation

Extract Direct Estimation

Y_direct=dataHBMEbeta[,1]
MSE_direct=dataHBMEbeta[,6]
RSE_direct=sqrt(MSE_direct)/Y_direct*100

Comparing Y

Y_HBMEbeta=example$Est$mean
Y=as.data.frame(cbind(Y_direct,Y_HBMEbeta))
summary(Y)
#>     Y_direct        Y_HBMEbeta    
#>  Min.   :0.1110   Min.   :0.5685  
#>  1st Qu.:0.8404   1st Qu.:0.8247  
#>  Median :0.9941   Median :0.8888  
#>  Mean   :0.8696   Mean   :0.8662  
#>  3rd Qu.:1.0000   3rd Qu.:0.9330  
#>  Max.   :1.0000   Max.   :0.9551

Comparing Mean Squared Error (MSE)

MSE=as.data.frame(cbind(MSE_direct,MSE_HBMEbeta))
summary(MSE)
#>    MSE_direct        MSE_HBMEbeta     
#>  Min.   :0.001290   Min.   :0.001564  
#>  1st Qu.:0.007948   1st Qu.:0.003232  
#>  Median :0.018572   Median :0.006417  
#>  Mean   :0.021281   Mean   :0.009938  
#>  3rd Qu.:0.033778   3rd Qu.:0.012832  
#>  Max.   :0.053116   Max.   :0.045976

Comparing Relative Standard Error (RSE)

RSE=as.data.frame(cbind(RSE_direct,RSE_HBMEbeta))
summary(RSE)
#>    RSE_direct       RSE_HBMEbeta   
#>  Min.   :  3.592   Min.   : 4.149  
#>  1st Qu.:  9.021   1st Qu.: 6.129  
#>  Median : 13.658   Median : 8.975  
#>  Mean   : 24.129   Mean   :11.147  
#>  3rd Qu.: 22.290   3rd Qu.:13.615  
#>  Max.   :184.551   Max.   :37.717

case 2: Auxiliary variables contains variable with error and without error

Fitting HB Model

example_mix <- meHBbeta(Y~x1+x2+x3, var.x = c("v.x1","v.x2"),
                   iter.update = 3, iter.mcmc = 10000,
                   thin = 3, burn.in = 1000, data = dataHBMEbeta)
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 30
#>    Unobserved stochastic nodes: 127
#>    Total graph size: 717
#> 
#> Initializing model
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 30
#>    Unobserved stochastic nodes: 127
#>    Total graph size: 717
#> 
#> Initializing model
#> 
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 30
#>    Unobserved stochastic nodes: 127
#>    Total graph size: 717
#> 
#> Initializing model

Ekstract Mean Estimation

Small Area Mean Estimation

example_mix$Est
#>             mean         sd      2.5%       25%       50%       75%     97.5%
#> mu[1]  0.8980684 0.06923267 0.7233736 0.8674034 0.9144626 0.9467044 0.9806286
#> mu[2]  0.8066356 0.12749885 0.4851386 0.7421566 0.8353921 0.9022824 0.9700434
#> mu[3]  0.9309735 0.05596103 0.7786179 0.9113348 0.9462113 0.9693046 0.9900450
#> mu[4]  0.9147342 0.06481366 0.7352006 0.8881099 0.9322504 0.9603363 0.9886225
#> mu[5]  0.9295161 0.05581004 0.7782805 0.9101722 0.9446793 0.9673416 0.9902206
#> mu[6]  0.8445237 0.10277150 0.5876149 0.7915649 0.8678021 0.9208346 0.9759075
#> mu[7]  0.5538984 0.20601441 0.1592877 0.3981105 0.5594646 0.7157703 0.9079447
#> mu[8]  0.9398540 0.04867329 0.8096888 0.9238159 0.9531790 0.9722107 0.9905376
#> mu[9]  0.8497605 0.10480620 0.5777270 0.8036341 0.8748737 0.9255933 0.9761312
#> mu[10] 0.9278065 0.05972509 0.7702155 0.9061382 0.9443924 0.9679990 0.9891576
#> mu[11] 0.9393884 0.05168950 0.7982325 0.9207418 0.9540165 0.9745104 0.9921615
#> mu[12] 0.8584706 0.09858856 0.6076867 0.8138746 0.8823699 0.9288904 0.9779432
#> mu[13] 0.7827440 0.13496190 0.4605178 0.7045604 0.8104771 0.8847835 0.9649510
#> mu[14] 0.8774947 0.08314641 0.6570440 0.8394734 0.8965291 0.9383229 0.9798672
#> mu[15] 0.9390030 0.04974905 0.8064487 0.9228411 0.9531126 0.9716245 0.9905746
#> mu[16] 0.8568864 0.09273005 0.6231279 0.8119917 0.8763112 0.9242298 0.9756419
#> mu[17] 0.7509284 0.16291593 0.3677454 0.6478261 0.7886412 0.8802919 0.9659139
#> mu[18] 0.9451789 0.05103827 0.8040990 0.9317344 0.9597483 0.9779117 0.9935199
#> mu[19] 0.9003160 0.07071304 0.7200515 0.8695961 0.9174238 0.9497746 0.9826099
#> mu[20] 0.9528903 0.04007412 0.8407603 0.9391775 0.9643419 0.9794624 0.9939327
#> mu[21] 0.9460703 0.05192265 0.8102811 0.9335542 0.9610167 0.9786218 0.9942006
#> mu[22] 0.8599969 0.09724178 0.6097388 0.8135664 0.8816138 0.9309615 0.9777706
#> mu[23] 0.8953223 0.08458860 0.6733433 0.8628152 0.9172511 0.9549114 0.9871341
#> mu[24] 0.7739139 0.12688952 0.4797136 0.6995445 0.7949209 0.8696316 0.9569087
#> mu[25] 0.9020343 0.06840686 0.7235145 0.8710492 0.9185632 0.9509798 0.9831488
#> mu[26] 0.8316515 0.09974879 0.5885373 0.7797420 0.8518261 0.9057774 0.9657469
#> mu[27] 0.7704305 0.16098890 0.3632368 0.6812450 0.8084677 0.8950614 0.9728091
#> mu[28] 0.9602631 0.03850634 0.8605278 0.9496817 0.9721546 0.9845448 0.9954454
#> mu[29] 0.7884464 0.12618375 0.4737107 0.7171177 0.8143351 0.8831183 0.9618207
#> mu[30] 0.8772239 0.11426874 0.5580084 0.8375973 0.9113780 0.9539848 0.9896342

Coefficient Estimation

example_mix$coefficient
#>           Mean        SD        2.5%        25%       50%       75%     97.5%
#> b[0] 0.8054494 0.3482690  0.13246212 0.56684540 0.7991990 1.0353675 1.5106592
#> b[1] 0.2841079 0.2818184 -0.26522259 0.09199265 0.2761318 0.4677725 0.8631830
#> b[2] 0.2970474 0.1148949  0.08029352 0.21728454 0.2968940 0.3737696 0.5246828
#> b[3] 0.9414691 0.5012962 -0.03096211 0.61151591 0.9311154 1.2866920 1.9406204

Random Effect Variance Estimation

example_mix$refvar
#> [1] 0.5735241

Extract MSE

MSE_HBMEbeta_mix=example_mix$Est$sd^2

Extract RSE

RSE_HBMEbeta_mix=sqrt(MSE_HBMEbeta_mix)/example_mix$Est$mean*100

You can compare with Direct Estimation

Comparing Y

Y_HBMEbeta_mix=example_mix$Est$mean
Y_mix=as.data.frame(cbind(Y_direct,Y_HBMEbeta_mix))
summary(Y)
#>     Y_direct        Y_HBMEbeta    
#>  Min.   :0.1110   Min.   :0.5685  
#>  1st Qu.:0.8404   1st Qu.:0.8247  
#>  Median :0.9941   Median :0.8888  
#>  Mean   :0.8696   Mean   :0.8662  
#>  3rd Qu.:1.0000   3rd Qu.:0.9330  
#>  Max.   :1.0000   Max.   :0.9551

Comparing Mean Squared Error (MSE)

MSE_mix=as.data.frame(cbind(MSE_direct,MSE_HBMEbeta_mix))
summary(MSE_mix)
#>    MSE_direct       MSE_HBMEbeta_mix  
#>  Min.   :0.001290   Min.   :0.001483  
#>  1st Qu.:0.007948   1st Qu.:0.003119  
#>  Median :0.018572   Median :0.007034  
#>  Mean   :0.021281   Mean   :0.009739  
#>  3rd Qu.:0.033778   3rd Qu.:0.012539  
#>  Max.   :0.053116   Max.   :0.042442

Comparing Relative Standard Error (RSE)

RSE_mix=as.data.frame(cbind(RSE_direct,RSE_HBMEbeta_mix))
summary(RSE_mix)
#>    RSE_direct      RSE_HBMEbeta_mix
#>  Min.   :  3.592   Min.   : 4.010  
#>  1st Qu.:  9.021   1st Qu.: 6.006  
#>  Median : 13.658   Median : 9.462  
#>  Mean   : 24.129   Mean   :11.035  
#>  3rd Qu.: 22.290   3rd Qu.:12.853  
#>  Max.   :184.551   Max.   :37.194
note : you can use dataHBMEbetaNS for using dataset with non-sampled area