Learn R Programming

rhnerm (version 1.1)

mseRHNERM: Mean squared error estimation of the empirical Bayes estimators under random heteroscedastic nested error regression models

Description

Calculates the mean squared error estimates of the empirical Bayes estimators under random heteroscedastic nested error regression models based on the parametric bootstrap.

Usage

mseRHNERM(y, X, ni, C, maxr=100, B=100)

Arguments

y
N*1 vector of response values.
X
N*p matrix containing N*1 vector of 1 in the first column and vectors of covariates in the rest of columns.
ni
m*1 vector of sample sizes in each area.
C
m*p matrix of area-level covariates included in the area-level parameters.
maxr
maximum number of iteration for computing the maximum likelihood estimates.
B
number of bootstrap replicates.

Value

m*1 vector of mean squared error estimates.

References

Kubokawa, K., Sugasawa, S., Ghosh, M. and Chaudhuri, S. (2016). Prediction in Heteroscedastic nested error regression models with random dispersions. Statistica Sinica, 26, 465-492.

Examples

Run this code
#generate data
set.seed(1234)
beta=c(1,1); la=1; tau=c(8,4)
m=20; ni=rep(3,m); N=sum(ni)
X=cbind(rep(1,N),rnorm(N))

mu=beta[1]+beta[2]*X[,2]
sig=1/rgamma(m,tau[1]/2,tau[2]/2); v=rnorm(m,0,sqrt(la*sig))
y=c()
cum=c(0,cumsum(ni))
for(i in 1:m){
  term=(cum[i]+1):cum[i+1]
  y[term]=mu[term]+v[i]+rnorm(ni[i],0,sqrt(sig[i]))
}

#fit the random heteroscedastic nested error regression
C=cbind(rep(1,m),rnorm(m))
mse=mseRHNERM(y,X,ni,C,B=10)
mse

Run the code above in your browser using DataLab