Write a complete algorithm for this gibbs sampling algorithm

Assignment Help Basic Statistics
Reference no: EM131055819

TEXTBOOK - COMPUTATIONAL STATISTICS SECOND EDITION By GEOF H. GIVENS AND JENNIFER A. HOETING

Problem 1-

Consider the data set "Rat_data.csv" (Read the data using the function read.csv()) in R. Each data point represents the weight of a rat at a certain age. More specifically, weights of 30 rats (in grams) were measured at five time points of x1 = 8, x2 = 15, x3 = 22, x4 = 29, x5 = 36(weeks). For example, weight of rat 3 in week 15 was 214 grams. Let yij denote the weight of rat i at age xj, and consider the following model for the yij

Yij ~ N(αi + βi(xj - x-), σ2) for i = 1, . . . , 30 and j = 1, . . . , 5 and x- = 22  

(a) Obtain the maximum likelihood estimate of αi, βi and σ2. Show your work, and compute the final estimates.

(b) Now consider a Bayesian analysis of this model, where we assume the following priors

αi ~ N(α, 100) with hyperprior     α ~ N(0,10000)

βi ~ N(β, 1)    with hyperprior       β~ N(0,10000)

?? = (1/σ2) ~ gamma(10-3, 10-3)

where ~αi, βi and ?? are assumed to be independent. Our aim here is to use the Gibbs sampling method to generate values from the posterior distribution of (α1, . . . , α30, β1, . . . , β30, τ).

(i) State all the required conditionals. Show your derivation very briefly. 

(ii) Write a complete algorithm for this Gibbs sampling algorithm, specific to this problem and code your algorithm, using R.

(iii) Run the chain for 50,000 iterations, and burn-in the first 10,000 generated values. Plot the chain (trace) after the burn-in for α1, β1, α15, β15, τ against the iteration number, and comment on the mixing. 

(iv) Draw the histograms for the posterior distribution of α1, β1, α15, β15, τ and provide a point estimate for each parameter.

(c) Obtain a 95% credible interval for each of the parameters α1, β1. Interpret your intervals in the context of the problem. 

(d) In the prior, we assumed that α1, β1 and τ are independent. Does the posterior support this assumption? Justify your answer.

Problem 2-

Consider simulation of the bivariate normal distribution with μ = (1, 2)T and covariance matrix

393_Figure.png

using Metropolis-Hastings algorithm with random walk generating density. Specifically, let x = x(t)+ε, where ε ~ N2(0, D) with D being a diagonal matrix with diagonal elements δ1 and δ2. Note that δ1 and δ2 control the spread of values generated along the first and second coordinate axis, respectively.

(a) Give the M-H algorithm, and code it in R. 

(b) Choose δ1 = 0.001 and δ2 = 0.001, and generate a chain, starting at x(0) = (0, 0)t, of size 10,000 using the M-H algorithm.

(i) Compute the acceptance rate, and comment on the acceptance rate. 

(ii) Burn 1000, and draw a trace plot and the density plot for the chain for each of the variables. Comment on mixing and the density plots. 

(iii) Draw 9000 pairs generated from multivariate normal with μ = (1, 2)T and covariance matrix

393_Figure.png

Plot these pairs on a scatterplot overlaying it with the last 9000 points obtained from the M-H chain; use different color for those generated from MH and those directly generated from the target (choosing an alpha-level for color transparency is helpful). Do the M-H generated values match the target? Explain why or why not. 

(c) Choose appropriate δ1 and δ2 so that the M-H algorithm would generate values that meet the target requirement. Draw a similar scatter-plot as in part a(ii) for this case. 

(d) How do you expect the acceptance rate would change, if you choose δ1 and δ2 to be very large? Briefly explain why?

I will need the assignment along with the R codes. R codes are extremely important in this course, please have some explanation in R file. Please try to avoid using built in packages if possible.

Attachment:- rats_data.rar

Reference no: EM131055819

Questions Cloud

Case involving breach of company directors duties : Research on an Australian case (not more than 10 years old) involving breach of company director's/officer's duties.
Topics for crmcal thinking and writing : 1.   By the end of the second paragraph did you think that the British are probably right to be cautious, to require approval for all requests fibi1/4 PGD? Explain your position.
Company just paid its annual dividend in the amount : The Onboard Co. is a new firm in a rapidly growing industry. The company is planning on increasing its annual dividend by 17.4 percent a year for the next 3 years and then decreasing the growth rate to 4.6 percent per year. The company just paid its ..
Dividend is increasing at constant : Shares of common stock of the Leafpad Co. offer an expected total return of 8.7 percent. The dividend is increasing at a constant 4.4 percent per year. What must be the dividend yield?
Write a complete algorithm for this gibbs sampling algorithm : State all the required conditionals. Show your derivation very briefly. Write a complete algorithm for this Gibbs sampling algorithm, specific to this problem and code your algorithm, using R
Shareholders as the annual dividend : Catfish, Inc. just paid $1.27 to its shareholders as the annual dividend. Simultaneously, the company announced that future dividends will be increasing by 4.37 percent. If you require a rate of return of 7.35 percent, how much are you willing to pay..
About the number on the ball : A bag contains an entire set of Bingo balls, numbered from 1 to 75. One ball is drawn at random from the bag. Which statement is true about the number on the ball?
The dividend is expected to grow at some constant rate : Crisp Cookware's common stock is expected to pay a dividend of $2.5 a share at the end of this year (D1 = $2.50); its beta is 0.70; the risk-free rate is 5.2%; and the market risk premium is 5%. The dividend is expected to grow at some constant rate ..
Operating leverage-slow-growth company to have debt ratio : What is operating leverage? How, if at all, is it similar to financialleverage? If a firm has high operating leverage would you expect it tohave high or low financial leverage? Explain your reasoning. Why might it make sense for a mature, slow-growth..

Reviews

Write a Review

Basic Statistics Questions & Answers

  Problem related to mean miles per gallon

Suppose a company owns three cars that get 20 miles per gallon, two cars that get 22 miles per gallon and one car that gets 24 miles per gallon. Would the mean miles per gallon be 22?

  A drag racer has two parachutes a main and a backup that

a drag racer has two parachutes a main and a backup that are designed to bring the vehicle to a stop after the end of

  In a doctors office there are nine nurses and eight

in a doctors office there are nine nurses and eight physicians. six nurses and four physicians are females. if a person

  Calculate expectations and variances of x and y

One of 4 bus drivers is also arbitarily chosen. Let Y denote number of students on his bus. Calculate expectations and variances of X and Y.

  A resent report indicated an average family of four 2

a resent report indicated an average family of four 2 parents and 2 children under the age of 16 spends 500 per month

  What is the test value for hypothesis

Their average cost was $405 with a standard deviation of $80. The Dean of Students believes that the costs are greater this semester. What is the test value for this hypothesis?

  Memorandum opinion on statistical significance

The following memorandum opinion on statistical significance was issued by the judge in a trial involving many scientific issues. The opinion has been stripped of some legal jargon and has been taken out of context.

  Formulate and solve linear program for determining question

Formulate and solve linear program for determining how many copies should be assigned to each printing firm to minimize the total cost of obtaining 75,000 acceptable-quality reports?

  Find a 95 confidence interval for the percentage of all

there are 30000 students enrolled at city university. 1 a simple random sample of 400 city university students was

  Chi-square test and regression analysis

What is the Chi-square test? Where can you apply it? Please site an example of how it was used and the outcome of the test. I think this could help me better than the book, it is difficult to understand.

  A simple random sample of 10 software widgets are chosen

a simple random sample of 10 software widgets are chosen for installation. if 10 of this type of software widgets have

  What is the probability of getting 2 aces

How many different 6-letter code words can be formed from the first 8 letters of the alphabet if adjacent letters must be different?

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