MCMChierEI {MCMCpack}R Documentation

Markov chain Monte Carlo for Wakefield's Hierarchial Ecological Inference Model


`MCMChierEI' is used to fit Wakefield's hierarchical ecological inference model for partially observed 2 x 2 contingency tables.


MCMChierEI(r0, r1, c0, c1, burnin=5000, mcmc=50000, thin=1,
           verbose=FALSE, seed=NA,
           m0=0, M0=2.287656, m1=0, M1=2.287656, a0=0.825, b0=0.0105,
           a1=0.825, b1=0.0105, ...)


r0 (ntables * 1) vector of row sums from row 0.
r1 (ntables * 1) vector of row sums from row 1.
c0 (ntables * 1) vector of column sums from column 0.
c1 (ntables * 1) vector of column sums from column 1.
burnin The number of burn-in scans for the sampler.
mcmc The number of mcmc scans to be saved.
thin The thinning interval used in the simulation. The number of mcmc iterations must be divisible by this value.
verbose A switch which determines whether or not the progress of the sampler is printed to the screen. Information is printed if TRUE.
seed The seed for the random number generator. If NA, the Mersenne Twister generator is used with default seed 12345; if an integer is passed it is used to seed the Mersenne twister. The user can also pass a list of length two to use the L'Ecuyer random number generator, which is suitable for parallel computation. The first element of the list is the L'Ecuyer seed, which is a vector of length six or NA (if NA a default seed of rep(12345,6) is used). The second element of list is a positive substream number. See the MCMCpack specification for more details.
m0 Prior mean of the mu0 parameter.
M0 Prior variance of the mu0 parameter.
m1 Prior mean of the mu1 parameter.
M1 Prior variance of the mu1 parameter.
a0 a0/2 is the shape parameter for the inverse-gamma prior on the sigma^2_0 parameter.
b0 b0/2 is the scale parameter for the inverse-gamma prior on the sigma^2_0 parameter.
a1 a1/2 is the shape parameter for the inverse-gamma prior on the sigma^2_1 parameter.
b1 b1/2 is the scale parameter for the inverse-gamma prior on the sigma^2_1 parameter.
... further arguments to be passed


Consider the following partially observed 2 by 2 contingency table for unit t where t=1,...,ntables:

| Y=0 | Y=1 |
- - - - - - - - - - - - - - - - - - - -
X=0 | Y0[t] | |r0[t]
- - - - - - - - - - - - - - - - - - - -
X=1 | Y1[t] | | r1[t]
- - - - - - - - - - - - - - - - - - - -
| c0[t] | c1[t] | N[t]

Where r0[t], r1[t], c0[t], c1[t], and N[t] are non-negative integers that are observed. The interior cell entries are not observed. It is assumed that Y0[t]|r0[t] ~ Binomial(r0[t], p0[t]) and Y1[t]|r1[t] ~ Binomial(r1[t],p1[t]). Let theta0[t] = log(p0[t]/(1-p0[t])), and theta1[t] = log(p1[t]/(1-p1[t])).

The following prior distributions are assumed: theta0[t] ~ Normal(mu0, sigma^2_0), theta1[t] ~ Normal(mu1, sigma^2_1). theta0[t] is assumed to be a priori independent of theta1[t] for all t. In addition, we assume the following hyperpriors: mu0 ~ Normal(m0, M0), mu1 ~ Normal(m1, M1), σ^2_0 ~ InvGamma(a0/2, b0/2), and σ^2_1 ~ InvGamma(a1/2, b1/2).

The default priors have been chosen to make the implied prior distribution for p0 and p1 approximately uniform on (0,1).

Inference centers on p0, p1, mu0, mu1, sigma^2_0, and sigma^2_1. Univariate slice sampling (Neal, 2003) along with Gibbs sampling is used to sample from the posterior density.

See Section 5.4 of Wakefield (2003) for discussion of the priors used here. MCMChierEI departs from the Wakefield model in that the mu0 and mu1 are here assumed to be drawn from independent normal distributions whereas Wakefield assumes they are drawn from logistic distributions.


An mcmc object that contains the posterior density sample. This object can be summarized by functions provided by the coda package.


Jonathan C. Wakefield. 2003. ``Ecological inference for 2x2 tables." Read before the Royal Statistical Society, on November 12th, 2003.

Radford Neal. 2003. ``Slice Sampling" (with discussion). Annals of Statistics, 31: 705-767.

Andrew D. Martin, Kevin M. Quinn, and Daniel Pemstein. 2004. Scythe Statistical Library 1.0.

Martyn Plummer, Nicky Best, Kate Cowles, and Karen Vines. 2002. Output Analysis and Diagnostics for MCMC (CODA).

See Also

MCMCdynamicEI, plot.mcmc,summary.mcmc


   ## Not run: 
## simulated data example 
n <- 100
r0 <- round(runif(n, 400, 1500))
r1 <- round(runif(n, 100, 4000))
p0.true <- pnorm(rnorm(n, m=0.5, s=0.25))
p1.true <- pnorm(rnorm(n, m=0.0, s=0.10))
y0 <- rbinom(n, r0, p0.true)
y1 <- rbinom(n, r1, p1.true)
c0 <- y0 + y1
c1 <- (r0+r1) - c0

## plot data
tomogplot(r0, r1, c0, c1)

## fit exchangeable hierarchical model
post <- MCMChierEI(r0,r1,c0,c1, mcmc=40000, thin=5, verbose=TRUE,
                    seed=list(NA, 1))

p0meanHier <- colMeans(post)[1:n]
p1meanHier <- colMeans(post)[(n+1):(2*n)]

## plot truth and posterior means
pairs(cbind(p0.true, p0meanHier, p1.true, p1meanHier))
   ## End(Not run)

[Package MCMCpack version 0.5-2 Index]