Package 'rhnerm'

Title: Random Heteroscedastic Nested Error Regression
Description: Performs the random heteroscedastic nested error regression model described in Kubokawa, Sugasawa, Ghosh and Chaudhuri (2016) <doi:10.5705/ss.202014.0070>.
Authors: Shonosuke Sugasawa
Maintainer: Shonosuke Sugasawa <[email protected]>
License: GPL (>= 2)
Version: 1.1
Built: 2024-11-15 06:41:11 UTC
Source: CRAN

Help Index


Conditional mean squared error estimation of the empirical Bayes estimators under random heteroscedastic nested error regression models

Description

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

Usage

cmseRHNERM(y, X, ni, C, k=1, 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.

k

area number in which the conditional mean squared error estimator is calculated.

maxr

maximum number of iteration for computing the maximum likelihood estimates.

B

number of bootstrap replicates.

Value

conditional mean squared error estimate in the kth area.

Author(s)

Shonosuke Sugasawa

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

#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))
cmse=cmseRHNERM(y,X,ni,C,B=10)
cmse

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.

Author(s)

Shonosuke Sugasawa

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

#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

Estimation of random heteroscedastic nested error regression models

Description

Calculates the maximum likelihood estimates of the model parameters in random heteroscedastic nested error regression models. The empirical Bayes estimates of area-level parameters with random effects are also given.

Usage

RHNERM(y, X, ni, C, maxr=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.

Value

The function returns a list with the following objects:

MLE

(p+3)*1 vector of maximum likelihood estimates of the model parameters.

EB

m*1 vector of empirical Bayes estimates of the area-level parameters.

Author(s)

Shonosuke Sugasawa

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

#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))
fit=RHNERM(y,X,ni,C)
fit