Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

SQB7009 Bayesian Statistics

Assignment 1

2022

1.        Suppose we have 1, … ,  with

 | ~ Bern().

(a)     Using the improper prior distribution () ∝  −1(1 − )−1 , find the posterior

distribution (|) up to proportionality, and find a Normal approximation about the mode to the posterior (|).

(b)     Show that the prior () is equivalent to a uniform prior on

 = log ()

and find the posterior (|). Find a Normal approximation about the mode to the posterior (|).

(c)     For  which  parameterization   does  it  make  more   sense  to  use   a  Normal approximation? Explain.

(d)    Based  on  your  answer  in part  (c),  write  a program  in  R to use the Normal approximation. Use the data  = ∑1   generated below, where  = 30:

 

set.seed(id)

p = round(runif(1, 0.2, 0.8), 2)

S = rbinom(1, 30, p)

list (p=p, S=S)

 

(i)        Plot  the  density  of the  Normal  approximation  about  the  mode  to  the posterior of the corresponding parameter.

(ii)       Using 1,000 samples from this Normal approximation (use set.seed(id)),

calculate the mean and variance of these samples. Compare them to the theoretical values from the Normal approximation.

(iii)      Using the  samples from part (ii), find the  (approximate) 99% credible

interval for the posterior mean of the corresponding parameter.


2.      Capture-recapture models are used to estimate the size  of a closed animal population. Suppose   is unknown, and each animal in the population has the probability   of being caught at any given time. At the first time point we capture  1  animals at random, tag them and release them back into the wild. At time 2 we capture  2   animals at random;  of these   11   are  already tagged.  Let   =  1  +  2   be the total number  of captures made, and  =   11 be the total number of unique animals captured.

(a)     Each animal can be in one of four situations: caught on both occasions, caught on

the first but not the second, caught on the second but not the first, and never caught. Let  be the number of animals in each situation, where  = 0, 1 denotes not captured and captured respectively on the first occasion, and  = 0, 1 denotes not captured and captured respectively on the second occasion. Find   and the corresponding probabilities  .

(b)    Assume that the data   have multinomial distribution with parameters   and

distribution given by

(00 ,  01,  10,  11 |, ) =   0(00)  1(01)  0(10)  

 

Find the likelihood of (, |, ).

(c)     Take independent priors for  and  with | ~ Po(), where  is known, and  ~ (0, 1). Find the joint posterior distribution (, |, ).

(d)    Find    an    expression    for   the   marginal    distribution,   (|, ),   up   to proportionality.

(e)     Consider  the  reparameterisation   =   .  Describe  how  we  may use  the

Gibbs  sample to produce  samples  from the joint posterior  (, |, ),  and hence how we might estimate the marginal mean [|, ].

(f)     Suppose we wish to estimate the size of the dolphin population in a marine area

of New Zealand. Experts believe that there are somewhere between 75 and 125 dolphins in the area; an appropriate choice of prior is as above with  = 100. On the first occasion we capture 36 dolphins on camera. A week later, we capture 48 on  camera,  of whom  27  are  identified  as  having been  observed  on  the  first occasion also.

(i)        Write a Gibbs sampler program in R to estimate the size of the population  . Note to include burn-in as part of your program.

(ii)       Using 1,000 samples and burn-in of 100 (use set.seed(id)), estimate the

value of  . Use the time series plots of  and  and other plots/methods to check for convergence.

 

3.       Let   ,  = 1, … ,  ,  be  exchangeable  where   | ~ Inv Gamma(, ),  where    is

known. Consider a prior distribution  ~ Gamma(, ).

(a)    Find the posterior distribution | .

(b)    We wish to use the Metropolis-Hastings algorithm to sample from the posterior

distribution  |  using a normal distribution with mean    and chosen constant variance  2  as the symmetric proposal distribution.

(i)     Describe how the Metropolis-Hastings algorithm works for this example, giving the acceptance probability in its simplest form.


(ii)    Suppose that, at time  , the proposed value  ∗  ≤ 0. Briefly explain why the

corresponding acceptance probability is zero for such a  ∗  and thus that the sequence of values generated by the algorithm are never less than zero.

(iii)   Does this normal proposal distribution result in an efficient algorithm? How

can this algorithm be improved? Explain.

(c)   Suppose instead for the Metropolis-Hastings algorithm in part (b), the proposal   is obtained by first sampling ̃ from a normal distribution with mean  and chosen variance  2  and then setting

 

   = { ̃       if  ̃ ≥ 0

 

Show that the associated proposal distribution is symmetric.

(d)    (i)     Write a program in R to estimate the posterior mean of   using the the Metropolis-Hastings algorithm in part (c). Note to include burn-in as part of your program.

(ii)    Let the data  ,  = 1, … ,  be generated below, where  = 20.

 

set.seed(id)

Y = round(1/rgamma(20, 1, 0.5),2) list (Y=Y)

 

Here  = 1. Use the prior values  = 0.5,  = 0.5. Using 10,000 samples and burn-in of 1000 (use set.seed(id)), and the proposal variance  2  = 252 , estimate  the  posterior  mean  of   .  Compare  it  to  the  theoritical  mean obtained using the distribution in part (a).

Also, use the time series plot of   and other plots/methods to check for convergence.