mspeNERdb | R Documentation |
This function returns MSPE estimator with double bootstrap method for Nested error regression model.
mspeNERdb(ni, formula, data, Xmean, K = 50, C = 50, method = 1, na_rm, na_omit)
ni |
(vector). It represents the sample number for every small area. |
formula |
(formula). Stands for the model formula that specifies the auxiliary variables to be used in the regression model. This should follow the R model formula syntax. |
data |
(data frame). It represents the data containing the response values and auxiliary variables for the Nested Error Regression Model. |
Xmean |
(matrix). Stands for the population mean of auxiliary values. |
K |
(integer). It represents the first bootstrap sample number. Default value is 50. |
C |
(integer). It represents the second bootstrap sample number. Default value is 50. |
method |
The variance component estimation method to be used. See "Details". |
na_rm |
A logical value indicating whether to remove missing values (NaN) from the input matrices and vectors.
If |
na_omit |
A logical value indicating whether to stop the execution if missing values (NaN) are present in the input data.
If |
This method was proposed by P. Hall and T. Maiti. Double bootstrap method uses boostrap tool twice for NER model to avoid the unattractivitive bias correction: one is to estimate the estimator bias, the other is to correct for bias.
Default value for method
is 1, method = 1
represents the MOM method, method = 2
and method = 3
represents ML and REML method, respectively.
This function returns a list with components:
MSPE |
(vector) MSPE estimates for NER model. |
bhat |
(vector) Estimates of the unknown regression coefficients. |
sigvhat2 |
(numeric) Estimates of the area-specific variance component. |
sigehat2 |
(numeric) Estimates of the random error variance component. |
Peiwen Xiao, Xiaohui Liu, Yu Zhang, Yuzi Liu, Jiming Jiang
F. B. Butar and P. Lahiri. On measures of uncertainty of empirical bayes small area estimators. Journal of Statistical Planning and Inference, 112(1-2):63-76, 2003.
N. G. N. Prasad and J. N. K. Rao. The estimation of the mean squared error of small-area estimators. Journal of the American Statistical Association, 85(409):163-171, 1990.
Peter Hall and T. Maiti. On parametric bootstrap methods for small area prediction. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 2006a.
H. T. Maiti and T. Maiti. Nonparametric estimation of mean squared prediction error in nested error regression models. Annals of Statistics, 34(4):1733-1750, 2006b.
Ni <- 1000
sigmaX <- 1.5
m <- 10
beta <- c(0.5, 1)
sigma_v2 <- 0.8
sigma_e2 <- 1
ni <- sample(seq(1, 10), m, replace = TRUE)
n <- sum(ni)
p <- length(beta)
pop.model <- function(Ni, sigmaX, beta, sigma_v2, sigma_e2, m) {
x <- rnorm(m * Ni, 1, sqrt(sigmaX))
v <- rnorm(m, 0, sqrt(sigma_v2))
y <- numeric(m * Ni)
theta <- numeric(m)
kk <- 1
for (i in 1:m) {
sumx <- 0
for (j in 1:Ni) {
sumx <- sumx + x[kk]
y[kk] <- beta[1] + beta[2] * x[kk] + v[i] + rnorm(1, 0, sqrt(sigma_e2))
kk <- kk + 1
}
meanx <- sumx / Ni
theta[i] <- beta[1] + beta[2] * meanx + v[i]
}
group <- rep(seq(m), each = Ni)
data <- data.frame(y = y, group = group, x1 = x)
return(list(data = data, theta = theta))
}
sampleXY <- function(Ni, ni, m, Population) {
Indx <- c()
for (i in 1:m) {
Indx <- c(Indx, sample(c(((i - 1) * Ni + 1):(i * Ni)), ni[i]))
}
Sample <- Population[Indx, ]
return(Sample)
}
Population <- pop.model(Ni, sigmaX, beta, sigma_v2, sigma_e2, m)$data
XY <- sampleXY(Ni, ni, m, Population)
formula <- y ~ x1
data <- XY
Xmean <- matrix(NA, m, p)
for (tt in 1:m) {
Xmean[tt, ] <- colMeans(Population[which(Population$group == tt), "x1", drop = FALSE])
}
result <- mspeNERdb(ni, formula, data, Xmean, K = 10, C = 10, method = 1)
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.