MATH3871-R代写
时间:2022-11-29
THE UNIVERSITY OF NEW SOUTH WALES
SCHOOL OF MATHEMATICS AND STATISTICS
Term 3 2021
MATH3871
Bayesian Inference and Computation
(1) TIME ALLOWED – THREE (3) HOURS
(2) TOTAL NUMBER OF QUESTIONS – 3
(3) ANSWER ALL QUESTIONS
(4) THE QUESTIONS ARE NOT OF EQUAL VALUE
(5) UPLOAD ONE OR TWO FILES FOR EACH QUESTION AND NAME THE
FILES ACCORDINGLY.
(6) THIS PAPER MAY BE RETAINED BY THE CANDIDATE
YOU ARE TO COMPLETE THE TEST UNDER STANDARD EXAM
CONDITIONS, WITH HANDWRITTEN SOLUTIONS AND R CODE.
YOU WILL THEN SUBMIT ONE OR MORE FILES CONTAINING YOUR
SOLUTIONS FOR EACH QUESTION. NAME THE FILES ACCORDING TO
THE NUMBER OF THE QUESTION. A MAXIMUM OF 20 FILES CAN BE UP-
LOADED. MAKE SURE YOU SUBMIT ALL YOUR ANSWERS.
ONE OF THE SUBMITTED FILES MUST INCLUDE A PHOTOGRAPH OF
YOUR STUDENT ID CARD WITH THE SIGNED, HANDWRITTEN
STATEMENT:
“I declare that this submission is entirely my own original work.”
YOU CAN DELETE AND/OR RELOAD FILES UNTIL THE DEADLINE.
Term 3 2021 MATH3871 Page 2
Question 1
1. [15 marks] Prior and Posterior computations. For this question upload hand-
written solutions.
i) [9 marks] Consider observations X1, . . . , Xn independent and identically
distribution such that Xi ∼ Ga(a, b) for i = 1, . . . , n, where Ga(a, b) indi-
cates a gamma distribution with shape parameter a and rate parameter
b. For a fixed a, define the Jeffreys’ prior for b. Is it proper?
ii) [3 marks] Given the Jeffreys’ prior computed in the previous point,
compute the posterior distribution. Is it proper?
iii) [3 marks] Again, consider observations X1, . . . , Xn independent and
identically distribution such that Xi ∼ Ga(a, b) for i = 1, . . . , n. Derive
the asymptotic posterior distribution for b.
Please see over . . .
Term 3 2021 MATH3871 Page 3
Question 2
2. [23 marks] Posterior computation and hypothesis testing. For points i), ii),
iii) upload handwritten solutions, for points i), iv) upload an R code (either
.R or .Rmd)
i) [5 marks] Over the past 50 years New South Wales has experienced
an average of λ0 = 75 large bushfires per year. Define Yi as the number
of bushfires for year i and consider Yi independent and identically dis-
tributed for i = 1, . . . , n according to a Poisson model with rate parameter
λ. For the next 10 years, New South Wales will record the number of
large fires and study if the rate has increased or decreased with respect
to the average seen so far.
You want to use a conjugate analysis. Select the parameter of the prior
distribution so that the variance is large and equal to 100 and Pr(λ >
λ0) = 0.5. (Hint: numerically, use lower bound equal to 0.01 and upper
bound equal to 10).
ii) [3 marks] Derive the posterior distribution of λ, given the observations
for the next 10 years and the prior distribution defined in part i).
iii) [8 marks] Consider the system of hypotheses: H0 : λ = λ0 vs H1 : λ 6=
λ0, where λ0 = 75. Analytically compute the Bayes Factor B01. Suppose
the mean for the next 10 year is y¯ = 57. What would be the preferred
hypothesis using the Bayes Factor?
iv) [7 marks] Approximate this Bayes Factor via Monte Carlo simulation,
by using simulation from the prior distribution to approximate the de-
nominator. Repeat the approximation 1000 times and plot the histogram
of the obtained approximations. Is the approximation you have obtained
good? Comment.
Please see over . . .
Term 3 2021 MATH3871 Page 4
Question 3
3. [22 marks] Monte Carlo methods. For this question upload handwritten
solutions and a file running the corresponding R code (.R or .Rmd files).
A cancer laboratory is estimating the rate of tumorigenesis in two strains of
mice, A and B. They have tumor count data for 10 mice in strain A and 13
mice in strain B. The observed tumor counts for the two populations are
yA = {12, 9, 12, 14, 13, 13, 15, 8, 15, 6}
yB = {11, 11, 10, 9, 9, 8, 7, 10, 6, 8, 8, 9, 7}
Consider YAi ∼ Pois(θA) for i = 1, . . . , nA and YBi ∼ Pois(θB) for i =
1, . . . , nB as the correspoding random variables for the counts of each pop-
ulation (A and B).
i) [5 marks] Reparametrize the model in θA = θ and
θB
θA
= γ. Consider
θ ∼ Ga(2, 1) and γ ∼ Ga(8, 8). Derive the full conditionals for θ|γ,yA,yB
and γ|θ,yA,yB and implement in R the relative Gibbs-sampling using
5000 simulations. Plot the obtained chains; after choosing an appropriate
burnin, estimate the posterior mean and variance of θ and γ.
ii) [5 marks] Reparametrize the model using θA = θ and
θA
θB
= γ. Consider
θ ∼ Ga(2, 1) and γ ∼ Ga(8, 8). Derive the full conditionals for θ|γ,yA,yB
and γ|θ,yA,yB and implement in R the relative Gibbs-sampling using
5000 simulations. For γ, obtain an acceptance rate around 23%. Plot
the obtained chains; after choosing an appropriate burnin, estimate the
posterior mean and variance of θ and γ.
iii) [3 marks] Choose two techniques among the ones introduced during
the course (plotting the chains is not including) to assess convergence and
apply them to the three Gibbs sampler algorithms you have implemented.
Comment the results.
iv) [9 marks] Consider the initial parametrization, i.e. YAi ∼ Poi(θA) for
i = 1, . . . , nA, and YBi ∼ Poi(θB) for i = 1, . . . , nB, but now consider θA
and θB to follow the same prior in a hierarchical model, i.e. θA ∼ Ga(α, β)
and θB ∼ Ga(α, β), with a, b ∼ Exp(0.1). Derive the full conditional
distributions of θA, θB, a, b and implement in R the corresponding Gibbs
sampler (consider a ∈ [0, 10]). Given the results of the Gibbs sampling,
test the hypothesis that θB < θA a posteriori looking at the posterior
distribution of the hypotheses (and assuming equal-probabilities a priori
for the hypotheses).
END OF EXAMINATION


essay、essay代写