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

SDS · School of Data Science

· Fall Semester 2023

DDA 4010  Bayesian Statistics

This exercise is due on Dec 17th, 11:59 pm.

Assignment A6.1 (10.5 in Textbook):

Logistic regression variable selection: Consider a logistic regression model for predicting diabetes  as a function of x1  = number of pregnancies, x2  = blood pressure, x3  = body mass index, x4  =  diabetes pedigree and x5  = age.  Using the data in azdiabetes.dat, center and scale each of the x  variables by subtracting the sample average and dividing by the sample standard deviation for each  variable.  Consider a logistic regression model of the form Pr (Yi  = 1 | i , β ) = eθi/1 + eθi

where

θi = β0 + β1γ1xi,1 + β2γ2xi,2 + β3γ3xi,3 + β4γ4xi,4 + β5γ5xi,5 .

In this model, each γj  is either 0 or 1 , indicating whether or not variable j is a predictor of diabetes. For example, if it were the case that γ = (1, 1, 0, 0, 0), then θi  = β0 + β1xi,1 + β2xi,2 .  Obtain posterior distributions for β and , using independent prior distributions for the parameters, such  that γj  ∼ binary(1/2), β0 ∼ normal(0, 16) and βj  ∼ normal(0, 4) for each j > 0.

a) Implement a Metropolis-Hastings algorithm for approximating the posterior distribution of β and . Examine the sequences βs)  and βs)  × γs)  for each j and discuss the mixing of the chain.

b) Approximate the posterior probability of the top five most frequently occurring values of γ . How good do you think the MCMC estimates of these posterior probabilities are?

c)  For each j, plot posterior densities and obtain posterior means for βjγj .   Also obtain Pr (γj  = 1 | g).

Assignment A6.2 (11.2 in Textbook):

Randomized block design: Researchers interested in identifying the optimal planting density for a type of perennial grass performed the following randomized experiment: Ten different plots of land were each divided into eight subplots, and planting densities of 2, 4, 6 and 8 plants per square meter were randomly assigned to the subplots, so that there are two subplots at each density in each plot. At the end of the growing season the amount of plant matter yield was recorded in metric tons per hectare. These data appear in the file pdensity.dat. The researchers want to fit a model like y = β1 + β2x + β3x2 + ϵ, where y is yield and x is planting density, but worry that since soil conditions vary across plots they should allow for some across-plot heterogeneity in this relationship. To accommodate this possibility, we will analyze these data using the hierarchical linear model described in Chapter 8.

a)  Before we do a Bayesian analysis, we will get some ad hoc estimates of these parameters via least squares regression. Fit the model y = β1 + β2x + β3x2 + ϵ using OLS for each group, and make a plot showing the heterogeneity of the least squares regression lines. From the least squares coefficients find ad hoc estimates of θ and Σ. Also obtain an estimate of σ2  by combining the information from the residuals across the groups.

b)  Now, we will perform an analysis of the data using the following distributions as prior

Σ 1 Wishart4,   1 

θ multivariate normal(θ(ˆ) )

σ 2  inverse-gamma1, σ(ˆ)2 

where θ(ˆ) , , σ(ˆ)2  are the estimates you obtained in a).  Note that this analysis is not combining

prior information with information from the data, as the "prior" distribution is based on the observed data. However, such an analysis can be roughly interpreted as the Bayesian analysis of an individual who has weak but unbiased prior information.

c)  Use a Gibbs sampler to approximate posterior expectations of β for each group j, and plot the resulting regression lines. Compare to the regression lines in a) above and describe why you see any differences between the two sets of regression lines.

d)  From your posterior samples, plot marginal posterior and prior densities of θ and the elements of Σ. Discuss the evidence that the slopes or intercepts vary across groups.

e)  Suppose we want to identify the planting density that maximizes average yield over a random sample of plots.  Find the value xmax  of x that maximizes expected yield, and provide a 95% posterior predictive interval for the yield of a randomly sampled plot having planting density xmax .