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

DDA 4010 – Bayesian Statistics

Exercise Sheet 6

Spring Semester 2022

Assignment A6.1 (10.5 in Textbook):

Logistic regression variable selection: Consider a logistic regression model for predicting diabetes as a function of z1 = number of pregnancies, z2 = blood pressure, z3 = body mass index, z4 = diabetes pedigree and z5 = age. Using the data in azdiabetes.dat, center and scale each of the z 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θ / 1 + eθ  where

9i = 80 + 81e1zi,1 + 82e2zi,2 + 83e3zi,3 + 84e4zi,4 + 85e5zi,5 .

In this model, each ej is either 0 or 1 , indicating whether or not variable j is a predictor of diabetes. For example, if it were the case that e = (1, 1, 0, 0, 0), then 9i  = 80 + 81zi,1 + 82zi,2.  Obtain posterior distributions for β and 卞 , using independent prior distributions for the parameters, such that ej  ~ binary(1/2), 80 ~ normal(0, 16) and 8j  ~ normal(0, 4) for each j > 0.

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

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

● For each j, plot posterior densities and obtain posterior means for 8jej.   Also obtain Pr (ej  = 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 = 81 + 82z + 83z2 + ∈, where y is yield and z 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 Section 11.1.  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 = 81 + 82z + 83z2 + ∈, where y is yield and z 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 Section 11.1.

● Before we do a Bayesian analysis we will get some ad hoc estimates of these parameters via least squares regression. Fit the model y = 81 + 82z + 83z2 + ∈ 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 72  by combining the information from the residuals across the groups.

● Now we will perform an analysis of the data using the following distributions as prior distributions:

Σ1   Wishart  4,  1

θ   multivariate normal (  , )

72   inverse   gamma 1, 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.

● 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.

● 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.

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