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.8983485 0.06788087 0.7281884 0.8671604 0.9139682 0.9456168 0.9803457
#> mu[2]  0.7831634 0.13585352 0.4572125 0.7069797 0.8098811 0.8872183 0.9637376
#> mu[3]  0.9292692 0.05731663 0.7877771 0.9088479 0.9451347 0.9671527 0.9887393
#> mu[4]  0.9134489 0.06648821 0.7431878 0.8846725 0.9299114 0.9601673 0.9877950
#> mu[5]  0.9121737 0.06510753 0.7414320 0.8862792 0.9293700 0.9573284 0.9853567
#> mu[6]  0.8535028 0.10197856 0.5896466 0.8040427 0.8766481 0.9288257 0.9786332
#> mu[7]  0.5794885 0.21535512 0.1653483 0.4127508 0.5940263 0.7543720 0.9333439
#> mu[8]  0.9417249 0.04693066 0.8144125 0.9253102 0.9539813 0.9731233 0.9915065
#> mu[9]  0.8628531 0.10178354 0.5921097 0.8180265 0.8871447 0.9357400 0.9822042
#> mu[10] 0.9318782 0.05421662 0.7889776 0.9130966 0.9457597 0.9684162 0.9887371
#> mu[11] 0.9468345 0.04460969 0.8315226 0.9312463 0.9591229 0.9762117 0.9918821
#> mu[12] 0.8145625 0.11499985 0.5172831 0.7561646 0.8397321 0.8993180 0.9658206
#> mu[13] 0.7812023 0.14149846 0.4375848 0.6991131 0.8109865 0.8918752 0.9686318
#> mu[14] 0.8965171 0.07563795 0.7033781 0.8638979 0.9149757 0.9492582 0.9841633
#> mu[15] 0.9381902 0.04821284 0.8093367 0.9201449 0.9508423 0.9711627 0.9901884
#> mu[16] 0.8693303 0.08884518 0.6431529 0.8308552 0.8922263 0.9322901 0.9771507
#> mu[17] 0.6803043 0.16771707 0.3110538 0.5700368 0.7023131 0.8110640 0.9344125
#> mu[18] 0.9500812 0.04390786 0.8348507 0.9357060 0.9624755 0.9784242 0.9942229
#> mu[19] 0.9169367 0.05855107 0.7665699 0.8917819 0.9312212 0.9578657 0.9849032
#> mu[20] 0.9546019 0.03569033 0.8636653 0.9400115 0.9640633 0.9794210 0.9938080
#> mu[21] 0.9365279 0.05694815 0.7926515 0.9184870 0.9517568 0.9726489 0.9924907
#> mu[22] 0.8467436 0.10532733 0.5645900 0.7980984 0.8726859 0.9216901 0.9735136
#> mu[23] 0.9004386 0.08118504 0.6822815 0.8675788 0.9231305 0.9568927 0.9886966
#> mu[24] 0.7759925 0.12449861 0.4812710 0.7036206 0.7981735 0.8695962 0.9538805
#> mu[25] 0.8808616 0.08122759 0.6804727 0.8443081 0.8990035 0.9390187 0.9777480
#> mu[26] 0.8490060 0.09509647 0.6140637 0.8025096 0.8708051 0.9182872 0.9668998
#> mu[27] 0.8229762 0.14041462 0.4518269 0.7576112 0.8652782 0.9285678 0.9813449
#> mu[28] 0.9568923 0.04164498 0.8504004 0.9459728 0.9685562 0.9826150 0.9949254
#> mu[29] 0.8028963 0.11992934 0.5135186 0.7356537 0.8265409 0.8953554 0.9639000
#> mu[30] 0.8814425 0.11110450 0.5846882 0.8441190 0.9144369 0.9568086 0.9914415

Coefficient Estimation

example$coefficient
#>           Mean        SD       2.5%       25%       50%       75%     97.5%
#> b[0] 1.1226650 0.3131415  0.5197233 0.9139235 1.1241285 1.3364265 1.7524778
#> b[1] 0.2910833 0.2681940 -0.2280189 0.1134587 0.2788845 0.4663728 0.8278934
#> b[2] 0.3528538 0.1052746  0.1492331 0.2794797 0.3540604 0.4253637 0.5617783

Random Effect Variance Estimation

example$refvar
#> [1] 0.5171439

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.5795  
#>  1st Qu.:0.8404   1st Qu.:0.8289  
#>  Median :0.9941   Median :0.8890  
#>  Mean   :0.8696   Mean   :0.8669  
#>  3rd Qu.:1.0000   3rd Qu.:0.9312  
#>  Max.   :1.0000   Max.   :0.9569

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.001274  
#>  1st Qu.:0.007948   1st Qu.:0.003254  
#>  Median :0.018572   Median :0.006594  
#>  Mean   :0.021281   Mean   :0.009782  
#>  3rd Qu.:0.033778   3rd Qu.:0.013005  
#>  Max.   :0.053116   Max.   :0.046378

Comparing Relative Standard Error (RSE)

RSE=as.data.frame(cbind(RSE_direct,RSE_HBMEbeta))
summary(RSE)
#>    RSE_direct       RSE_HBMEbeta   
#>  Min.   :  3.592   Min.   : 3.739  
#>  1st Qu.:  9.021   1st Qu.: 6.103  
#>  Median : 13.658   Median : 9.119  
#>  Mean   : 24.129   Mean   :11.010  
#>  3rd Qu.: 22.290   3rd Qu.:13.740  
#>  Max.   :184.551   Max.   :37.163

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.9024375 0.06820457 0.7274408 0.8695031 0.9200263 0.9510111 0.9843410
#> mu[2]  0.8004876 0.12984301 0.4815828 0.7320277 0.8253323 0.8984041 0.9714919
#> mu[3]  0.9348118 0.05621161 0.7788527 0.9118562 0.9514889 0.9734926 0.9935792
#> mu[4]  0.9196667 0.06423965 0.7457110 0.8950217 0.9360253 0.9641695 0.9906100
#> mu[5]  0.9330630 0.05678211 0.7839926 0.9129760 0.9492377 0.9715752 0.9917006
#> mu[6]  0.8496190 0.10173233 0.5968676 0.7981583 0.8714487 0.9252202 0.9788917
#> mu[7]  0.5259556 0.21472447 0.1350939 0.3562199 0.5338424 0.6963733 0.9107225
#> mu[8]  0.9441774 0.04773705 0.8172939 0.9271375 0.9572840 0.9763021 0.9937375
#> mu[9]  0.8547721 0.10767737 0.5795828 0.8053787 0.8827461 0.9320897 0.9813770
#> mu[10] 0.9359702 0.05299995 0.7985774 0.9152584 0.9502954 0.9726479 0.9923272
#> mu[11] 0.9445929 0.04977149 0.8135961 0.9270678 0.9588117 0.9781712 0.9951111
#> mu[12] 0.8576986 0.09962493 0.5834640 0.8130441 0.8812662 0.9275645 0.9777799
#> mu[13] 0.7734493 0.13906734 0.4415977 0.6909448 0.8016329 0.8794098 0.9645857
#> mu[14] 0.8799398 0.08603220 0.6511092 0.8413214 0.9022418 0.9409255 0.9814547
#> mu[15] 0.9432186 0.04807749 0.8082408 0.9263627 0.9559837 0.9753546 0.9937385
#> mu[16] 0.8550000 0.09948115 0.6046068 0.8051274 0.8773218 0.9280997 0.9799286
#> mu[17] 0.7263200 0.17829407 0.3090890 0.6166389 0.7638726 0.8718358 0.9601424
#> mu[18] 0.9497877 0.04785800 0.8157466 0.9353039 0.9644665 0.9804014 0.9950214
#> mu[19] 0.9047970 0.07280050 0.7123657 0.8736789 0.9245713 0.9557550 0.9865729
#> mu[20] 0.9559232 0.04057904 0.8540806 0.9433600 0.9669590 0.9820566 0.9956041
#> mu[21] 0.9477753 0.05028762 0.8183232 0.9328140 0.9622302 0.9800601 0.9947948
#> mu[22] 0.8657464 0.09886882 0.6050951 0.8225833 0.8916223 0.9357497 0.9827936
#> mu[23] 0.9026224 0.08589845 0.6686604 0.8715593 0.9284543 0.9609826 0.9901359
#> mu[24] 0.7701396 0.12543682 0.4727934 0.6963500 0.7920385 0.8636939 0.9517721
#> mu[25] 0.9032159 0.07169146 0.7191233 0.8731807 0.9203571 0.9537566 0.9853078
#> mu[26] 0.8328392 0.10674395 0.5642095 0.7814324 0.8546548 0.9116295 0.9710154
#> mu[27] 0.7627762 0.17463819 0.3314262 0.6618818 0.8090600 0.8983981 0.9742644
#> mu[28] 0.9630251 0.03714162 0.8628852 0.9525836 0.9741848 0.9865862 0.9968635
#> mu[29] 0.7859377 0.12623823 0.4873851 0.7149443 0.8091693 0.8798538 0.9605000
#> mu[30] 0.8867824 0.10602294 0.5950319 0.8486053 0.9188583 0.9588409 0.9922237

Coefficient Estimation

example_mix$coefficient
#>           Mean        SD        2.5%        25%       50%       75%     97.5%
#> b[0] 0.7402318 0.3684003  0.02678424 0.48534897 0.7371865 0.9898286 1.4654604
#> b[1] 0.3101258 0.3207736 -0.30045921 0.09104359 0.2961396 0.5136712 0.9599440
#> b[2] 0.3342182 0.1324559  0.08106114 0.24280255 0.3297780 0.4241445 0.6062353
#> b[3] 0.9407205 0.5228231 -0.06505794 0.58590682 0.9439613 1.2934871 1.9497187

Random Effect Variance Estimation

example_mix$refvar
#> [1] 0.593958

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.5795  
#>  1st Qu.:0.8404   1st Qu.:0.8289  
#>  Median :0.9941   Median :0.8890  
#>  Mean   :0.8696   Mean   :0.8669  
#>  3rd Qu.:1.0000   3rd Qu.:0.9312  
#>  Max.   :1.0000   Max.   :0.9569

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.001380  
#>  1st Qu.:0.007948   1st Qu.:0.002897  
#>  Median :0.018572   Median :0.007390  
#>  Mean   :0.021281   Mean   :0.010285  
#>  3rd Qu.:0.033778   3rd Qu.:0.011544  
#>  Max.   :0.053116   Max.   :0.046107

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.   : 3.857  
#>  1st Qu.:  9.021   1st Qu.: 5.750  
#>  Median : 13.658   Median : 9.647  
#>  Mean   : 24.129   Mean   :11.343  
#>  3rd Qu.: 22.290   3rd Qu.:12.762  
#>  Max.   :184.551   Max.   :40.826
note : you can use dataHBMEbetaNS for using dataset with non-sampled area