python代写-STAT8150/7150-Assignment 3
时间:2021-05-17
Bayesian Data Analysis Assignment 3: Due Week 12, 2021 STAT8150/7150: Bayesian Data Analysis Instructions: This assignment covers materials in weeks 7-10. This assignment is worth 40 marks. 1. Due on 30th May 2021. 2. For all the questions please provide the relevant mathematical derivations, the com- puter programs (only using R software) and the plots. 3. Please submit on iLearn a single PDF file containing all your work (code, compu- tations, plots, etc.). Other file formats (e.g. Word, html) will NOT be accepted. 4. Try to use Rmarkdown through Rstudio, But it is not compulsory to use Rmarkdown even if facilitate to reproduce results. Only upload the pdf file. 1 of 3 Bayesian Data Analysis Assignment 3: Due Week 12, 2021 Question 1 (12 marks) Suppose a single observation Y conditional on λ is Poisson with mean λ, and λ has a Gamma(a, b) prior with density equal to π(λ) = ba Γ(a) λa−1 exp(−bλ). (a) (2 marks) Write down the joint density of Y and λ. (b) (2 marks) Identify the conditional distribution Y conditional on λ, and the condi- tional distribution of λ conditional on Y = y. You need to specify the distribution family and corresponding parameters. (c) (4 marks) Use information from part (b) to construct a Gibbs sampling algorithm to sample from the joint distribution of (Y,λ) and write your own R function to implement it (not in JAGS). (d) (4 marks) Use the R function in part (c) to run 1000 iterations of Gibbs sampling for the case where a = 3 and b = 3. Report your simulated draw of Y and corresponding relative frequencies. Question 2 (10 marks) A person’s arm span is strongly related to one’s height. To investigate this relationship, arm spans and heights were measured (in cm) for a sample of 20 students and stored in the file armheight.csv which is available at iLearn page. Consider the regression model Yi ∼ Normal(µi,σ2) where µi = β0 + β1xi, where yi and xi are respectively the height and arm span for the i-th student. (a) (5 marks) Suppose that one assigns the weakly informative prior the parameters, where β0 ∼ Normal(0, 1002) and β1 ∼ Normal(0, 1002) and σ2 ∼ InvGamma(0.1, 0.1). Use JAGS to obtain a simulated sample from the posterior distribution. Find the posterior means of the regression intercept and slope and interpret these posterior means in the context of the problem. (b) (5 marks) Rescale the heights and arm spans and consider the alternative regression model Y ∗i ∼ Normal(µi,σ2), where µi = β0 + β1x ∗ i , and x ∗ i and y ∗ i are the rescaled measurements found by sub- tracting the respective means and dividing by the respectively standard deviations, i.e. standardized. By using similar weakly informative priors as in part (a), use JAGS to simulate from the joint posterior distribution. Find the posterior means of the regression parameters for this rescaled problem and interpret the means. Also return four diagnostic plots (trace plot, empirical CDF, histogram and autocorrelation plot) for the regression parameters. 2 of 3 Bayesian Data Analysis Assignment 3: Due Week 12, 2021 Question 3 (18 marks) What factors determine admission to graduate school? In a study, data on 400 graduate school admission cases was collected. Admission is a binary response, with 0 indicating not admitted, and 1 indicating admitted. Moreover, the applicants GRE score, and under- graduate grade point average (GPA) are available. The dataset GradSchoolAdmission.csv is available at iLearn (GRE score is out of 800). Let pi denote the probability that the i-th student is admitted. Consider the logistic model. log ! pi 1− pi " = β0 + β1xi1 + β2xi2, where x1i and x2i are respectively the GRE score and the GPA for the i-th student. (a) (3 marks) Assuming weakly informative priors on β0, β1, and β2, write a JAGS script defining the Bayesian model. (b) (3 marks) Write a script to take a sample of 5000 draws from the posterior distri- bution of β = (β0,β1,β2). (c) (4 marks) Consider a student with a 550 GRE score and a GPA of 3.50. Construct a 90% interval estimate for the probability that this student is admitted to graduate school. (d) (4 marks) Consider a student with a 580 GRE score. Construct 90% posterior interval estimates for the probability that this student achieves admission for GPA values equally spaced from 3.0 to 3.8. Graph these posterior interval estimates as a function of the GPA. (Hint: You may find the sapply function in R helpful.) (e) (4 marks) Consider a student with a 3.4 GPA. Find 90% interval estimates for the probability this student is admitted for GRE score values equally spaced from 520 to 700. Graph these interval estimates as a function of the GRE score. 3 of 3



























































































学霸联盟


essay、essay代写