## Transcribed Text

3. Suppose a pen manufacturing process has two steps. Precursors of the finished items are made
in batches, and then the batches are used to produce the individual items. If a key measurement
on the final items shows excessive variability, the question arises whether this variability may
arise mainly at the batch level or mainly at the final stage of the overall process. In order
to reduce variability, we need to understand where it arises. Assuming normal distribution of
errors, the measured value of the 3th item in the 1th batch is
where A, ~ N(0. VBA) and ~ N(0. and all A, and w are mutually independent. Thus
measurements on items across batches are independent but two measurements Th and for
two objects j and j in the 1th batch are correlated We thus have the following
Var(zig) and p(Ing-Iag) = 8A
where P is called the intra-class correlation. Download the dataset called pen.dat from the
Blackboard Each row of the dataset corresponds to a batch and there are 9 = 15 batches
with r - 10 items in each batch. We will do a a Bayesian analysis and for that we need prior
distributions. The prior distributions are
(Bo). DA-1G(a0.ko).
where IG stands for the inverse gamma distribution.
(a) Construct box-plots for the whole data to depict the group means. Based on the box-plot.
would you say that there is variance among the batches?
5 points]
(b) Implement a Gibbs sampler and construct Bayesian posterior mean estimates for and
8. Use the estimates so obtained to construct an estimate of the intra-class correlation
Use m = 50,000 iterations of the sampler and discard the first 10,000 iterations. In order
to run the Gibbs sampler you would need the posterior distributions They are given by
where
= and
Further
=
and
B = Bo +gr/2 and = +
In the above the g elements of A are
~
For prior parameter values use Pe = 0.001, Ko 0.001,80 = 0.001,1 to =
0.001. Use the group means as the initial values for the random effects A, that are not
observable in the data.
[15 points]
(c) Construct a 95% Bayesian posterior interval for p. BA and the intra-class correlation and
depict the interval using vertical lines on the respective histograms
[10 points]
(d)
Construct a trace-plot of the simulations of 0A and comment on whether it is a good
mixing chain. Use the built-in R function called act to do an autocorrelation plot of 8A
and use the plot to assess convergence. These plots are beyond the burn-in of the first
5000 iterations.
5 points

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

# 1

# (d)

Simulate.Gamma <- function(alpha, beta) {

a <- floor(alpha)

b <- beta*a/alpha

M <- ( (alpha-a)/(beta-b) )^(alpha-a)*exp(-(alpha-a)) *beta^alpha / b^a

trials <- 1

isRejected <- TRUE

while(isRejected) {

y <- rgamma(1,shape=a,scale=1/b)

f.alpha.beta <- (beta^alpha)/gamma(alpha)*y^(alpha-1)*exp(-beta*y)

g.a.b <- (b^a)/gamma(a)*y^(a-1)*exp(-b*y)

ratio <- f.alpha.beta/(g.a.b*M)

if (ratio >= runif(1) ) {

x <- y

isRejected <- FALSE

return( list(x,trials) )

} else {

trials <- trials + 1

}

}

}

Simulate.Gamma...