Write pseudo code for gibbs sampling

Assignment Help Mathematics
Reference no: EM132781049

Homework

Question 1. Give an advantage and a disadvantage of the following methods: Maximum a posteriori estimation, Numerical integration, Gibbs sampling, Metropolis-Hastings.

Question 2. Consider the sample x = (0.12, 0.17, 0.32, 0.56, 0.98, 1.03, 1.10, 1.18, 1.23, 1.67, 1.68, 2.33), generated from an exponential mixture x ∼ (Πg(x) + (1 - Π) h(x)). All parameters Π, λ, µ are unknown. Note xi|Zi = 1 ∼ exp(λ) = g(x), xi|Zi = 2 ∼ exp(µ) = h(x).

(a). Show that the likelihood L(Π, λ, µ; x) can be expressed as L(Π, λ, µ; x) = E (Lc(x, Z)), where z = (z1, . . . , z12) corresponds to the vector of allocations of the observations xi to the first and second components of the mixture; that is, for i = 1, . . . , 12,

p (zi = 1) = 1 - p (zi = 2) = Πλ exp (-λxi)/(Πλ exp (-λx ) + (1 - Π) µ exp (-µxi))

(b). Construct an EM algorithm for this model, and derive the maximum likelihood estimators of the parameters for the sample provided above. Hint: See the session (5.4.2) and (5.4.3) Christian Robert and George Casella, pag. 166.

Question 3. Generate a sample X = (x1, . . . , xn), of size n = 5000 from the N (µ, σ2) distribution where µ ∼ N (µ0, τ2) and σ2 ∼ Inv - Gamma (n0/2, S0/2) are independent. (You have the freedom of choice for the values of the hyperparameters, µ, τ2, n0 and S0).

(a). Obtain the posterior mode of p (µ, σ2|X) using Newton-Raphson. (b). Calculate E (µ|X) and E (σ2|X) using the Normal approximation.

Question 4. Consider a random variable x described by an exponential distribution with parameter λ. x ∼ exp(λ). We are uncertain about the value of λ and can choose to model this uncertainty by defining a Gamma distribution over it, λ ∼ Gamma(α, β).

(a). Derive the maximum likelihood estimate (MLE) (λMLE).
(b). Obtain an analytic form of the posterior distribution, and derive the maximum a posteriori estimator (MAP), (λMAP ) as a function of α, and β.
(c). Generate N = 20 samples drawn from an exponential distribution with parameter λ = 0.2. Fix β = 100 and vary α over the range (1 - 40), using a step-size of 1.

• Compute the corresponding MLE and MAP estimates for λ.
• For each α, compute the mean squared error (MSE) of both estimates compared against the true value and then plot the mean squared error as a function of α.

• Now, fix α = 30, β = 100 and vary N over the range (1-50) using a step-size of 1. Plot the mean squared error for each N of the corresponding estimates and explain under what conditions is the MAP estimator better. Where Mean square error (MSE) is defined as:

MSE =1/N NΣi=1 (Yi - Yˆi)2

where Yi is the true value and Yˆi is the estimated value.

Question 5. Consider the model yi2 ∼ N (0, σ2), i = 1, . . . , n, where σ2|b ∼ Inv - Gamma (a, b), b ∼ Gamma (1, 1).
(a). Derive the full conditional posterior distributions for σ2 and b.
(b). Write pseudo code for Gibbs sampling, i.e., describe in detail each step of the Gibbs sampling algorithm.
(c). Write your own Gibbs sampling code (R), report the posterior summary and plot the marginal posterior density, boxplot, trace for each parameter. Assume n = 10, a = 10, and Yi = i for i = 1, . . . , 10.
(d). Repeat the analysis with a = 1 and comment on the convergence of the MCMC chain.

Question 6. Consider the model yi = βxi + ui, ~ ui ∼ N (0, 1), i = 1, . . . , n. with the gamma prior distribution β ∼ Gamma(2, 1), β > 0. Verify the posterior distribution

p (β|y) ∝ β exp[-β] exp {-1/2 Σni=1 (yi - βxi)2} 1β∈(0,∞)

Note that this distribution does not have a standard form. Construct an MH algorithm to sample from this distribution with an independence kernel, where the kernel is a Student- t distribution truncated to the region (0, ∞), with five degrees of freedom, mean equal to the value of β that maximizes the posterior distribution (βˆ), and scale factor equal to the negative inverse of the second derivative of the log posterior distribution evaluated at (βˆ). Verify that

β = Σni=1(xiyi - 1) + √.(Σni=1 (xiyi - 1))2 4 Σni=2xi2ni=1 xi2

and that the scale factor is (1/β2 + Σni=1xi2). Generate a data set by choosing n = 50, xi from N (0, 1), and a value of β from its prior distribution. Write a program to implement your algorithm and see how well β is determined. You may try larger values of n to explore the effect of sample size, and, depending on the acceptance rate, you may wish to change the scale factor.

Attachment:- BAYESIAN HOMEWORK.rar

Reference no: EM132781049

Questions Cloud

How much will you have : How much will you have if you wait 10 years before beginning to save and only make 37 payments into your retirement? account
Explain piaget and erikson theories of development : -Briefly explain Piaget's and Erikson's theories of development. Who had a better theory of human development: Erikson or Piaget? Please offer detail to explain
Are persons labeled on delancey street : Are persons labeled on Delancey Street? Explain. What is the goal of Delancey Street? What is your opinion about programs such as Delancey Street?
Difference between normality and abnormality : What is the difference between normality and Abnormality? What is Normality?
Write pseudo code for gibbs sampling : Write pseudo code for Gibbs sampling - Repeat the analysis with a = 1 and comment on the convergence of the MCMC chain
Evaluate the accounting treatment for intangible assets : Evaluate the accounting treatment for intangible assets (other than goodwill) and contingent liabilities within consolidated financial statements
What was your reaction to online harassment of female gamers : What was your reaction to the online harassment of female gamers and of women who critique video games, as described in this post? Think of another example.
What is joan filing status : What is Joan's filing status for 2016, 2017, 2018, and 2019? Would Joan's filing status change if Marley attended school full-time rather than part-time
How to manage a client diverse needs : As a social worker how to manage a client's (her) diverse needs who is diagnosed with dissociative amnesia?

Reviews

Write a Review

Mathematics Questions & Answers

  Slope intercept from equation into standard form

Convert the slope intercept from equation into standard form, where A B and C are integers and A>0.

  At what speed is the area of the ripple increasing

A rock is thrown into a still pond and causes a circular ripple. If the radius of the ripple is increasing at a rate of 5 ft/sec, at what speed is the area of the ripple increasing when its radius is 15 feet?

  What is the temperature of the second bath

Math Questions - In a different water bath, the same cooling occurs in 70 seconds. What is the temperature of the second bath

  Maximum likelihood estimator

What is the maximum likelihood estimator of the mean of x where x is the sample with distribution f(x)=rt^x where t= 1-r and r is between 0 and 1 and the mean of rt^x is t/r.

  State interfere with the natural process of evolution

Environmentalists are always concerned about endangered species. It's a lucky thing that environmentalism itself is a new thing-those people want to interfere with the natural process of evolution.

  What is the probability that the mean height

What is the probability that the mean height of your sample is between 69 and 71 inches?

  Probability of the patients infected with hiv test positive

Suppose that 8% of the patients tested in a clinic are infected with HIV. Furthermore, suppose that when a blood test for HIV is given, 98% of the patients.

  Use the definition of derivative to prove

Let f(x)=x^1/3 for x ?R and use the definition of derivative to prove f'(x)=1/3(x)^-2/3  for not equal to zero

  How many tickets will be sold that day

the number of tickets sold each day for an upcoming perfomance of Hendel's Messiah is given by N(x)=-0.4x^2+8x+10, where x is the number of days since the concert was announced.when will daily ticket sales peak and how many tickets will be sold th..

  What is your new fico score

If your FICO score will drop 10% in the "payment history" category because of the late payment on your credit card, what is your new FICO score

  Marketing and ethical issues associated with these sites

1. What are the marketing and ethical issues associated with these sites? 2. As this consumer group ages will these issues become more or less important?

  To what length must ladder be extended to reach at window

In a practice fire mission, a ladder extended 10.0 ft just reaches the bottom of a 2.50-ft high window if the foot of the ladder is 6.00 ft from the wall.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd