knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(BayesSampling)
In a simple model, where there is no auxiliary variable, and a Simple Random Sample was taken from the population, we can calculate the Bayes Linear Estimator for the individuals of the population with the BLE_SRS() function, which receives the following parameters:
Letting $v \to \infty$ and keeping $\sigma^2$ fixed, that is, assuming prior ignorance, the resulting estimator will be the same as the one seen in the design-based context for the simple random sampling case.\
This can be achieved using the BLE_SRS() function by omitting either the prior mean and/or the prior variance, that is:
data(BigCity) set.seed(1) Expend <- sample(BigCity$Expenditure,10000) mean(Expend) #Real mean expenditure value, goal of the estimation ys <- sample(Expend, size = 20, replace = FALSE)
Our design-based estimator for the mean will be the sample mean:
mean(ys)
Applying the prior information about the population we can get a better estimate, especially in cases when only a small sample is available:
Estimator <- BLE_SRS(ys, N = 10000, m=300, v=10.1^5, sigma = sqrt(10^5)) Estimator$est.beta Estimator$Vest.beta Estimator$est.mean[1,] Estimator$Vest.mean[1:5,1:5]
ys <- c(5,6,8) N <- 5 m <- 6 v <- 5 sigma <- 1 Estimator <- BLE_SRS(ys, N, m, v, sigma) Estimator
ys <- mean(c(5,6,8)) n <- 3 N <- 5 m <- 6 v <- 5 sigma <- 1 Estimator <- BLE_SRS(ys, N, m, v, sigma, n) Estimator
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.