# I need help with a bayesian analysis assignment

It is done using the coding software R and the JAGS software package in R. I would need all R code and plots along with the answers to each of the questions. It is due next Monday April 6 so I would need it done before then. Attached is the assignment and data file required. Any help would be greatly appreciated

## Get Help With a similar task to - I need help with a bayesian analysis assignment

obs1 obs2 obs3 obs4 obs5 obs6 obs7 -3.72 -1.40 -0.44 -0.25 1.16 2.67 2.42 -3.60 -2.42 0.24 1.44 2.25 3.20 3.55 -1.01 0.64 2.58 2.64 3.56 4.46 6.16 -4.05 -1.11 0.66 0.99 2.44 4.35 4.58 -1.15 -0.21 -0.20 1.99 1.03 2.77 3.78 -1.79 1.45 2.49 2.54 3.38 4.25 5.48 -2.92 0.14 2.34 1.18 3.05 3.87 4.22 -4.79 -2.38 -1.01 0.15 0.39 1.98 1.84 -3.10 -2.27 -0.88 2.32 1.09 2.36 3.17 -2.96 -0.78 0.37 0.64 1.43 2.10 3.79 -1.26 0.24 2.15 2.92 3.65 3.91 4.11 -0.64 -0.10 0.68 1.55 2.12 3.46 3.35 -0.82 -0.12 1.33 1.54 2.32 2.39 2.60 -1.58 -0.39 0.08 1.15 1.59 4.31 4.44 -3.73 -1.27 -0.27 0.44 1.05 2.05 3.92 -0.52 1.43 2.90 4.12 3.88 4.44 6.49 -2.95 -0.90 0.49 1.28 2.53 4.16 5.12 -6.14 -4.05 -1.80 -1.24 -0.20 1.86 1.66 -0.27 0.24 1.64 1.72 2.44 2.76 3.89 -1.05 -0.22 -0.15 0.17 0.67 2.16 0.99 -4.73 -1.34 -0.74 -0.61 0.65 2.27 2.50 -2.57 -0.90 0.50 1.89 1.57 2.89 3.13 -3.29 -2.52 -0.79 -0.21 0.69 2.06 3.10 -3.40 -2.07 -1.25 0.33 1.46 2.88 3.65 -2.70 -2.13 0.40 0.32 1.33 2.03 2.77 -3.57 -3.17 -0.84 -0.55 -0.39 0.41 0.84 -1.60 1.09 1.51 2.42 3.71 4.49 5.14 -2.59 0.60 0.88 2.52 1.45 2.99 4.22 -4.31 -2.49 -1.21 -0.60 0.46 1.69 0.98 -1.27 1.28 3.22 3.55 4.03 3.55 4.79 -1.96 0.30 1.13 1.11 3.38 3.70 3.86 -2.76 -2.06 0.62 0.74 2.22 2.74 3.77 -0.60 0.42 2.29 1.72 2.65 4.65 4.57 -2.91 -0.57 1.56 2.86 3.10 4.37 5.17 -1.55 -0.15 1.51 1.42 3.32 3.96 4.46 -2.20 0.47 0.34 1.94 3.02 3.36 4.66 -1.42 0.03 -0.02 3.37 2.51 3.73 4.05 -2.99 -0.80 0.38 1.54 1.72 3.72 3.72 -2.40 -2.38 -0.04 1.49 2.19 2.58 3.06 -3.37 -1.40 -0.82 0.94 1.82 2.72 2.70 -3.32 -0.89 0.06 -0.10 1.03 2.32 2.38 -3.49 -0.25 0.00 0.72 2.47 1.92 3.30 -5.84 -2.95 -0.99 -0.71 0.51 1.90 3.03 -0.42 1.87 3.68 3.55 4.59 5.44 5.81 -2.52 -0.22 1.69 1.47 3.93 5.42 6.34 -5.42 -1.68 -0.64 0.18 1.76 1.76 2.68 -1.54 -1.11 1.09 0.04 1.40 2.48 2.99 -2.85 -0.88 -0.41 1.09 1.84 0.66 2.99 -1.76 0.71 1.99 2.09 2.44 3.57 4.20 -2.38 -2.05 -0.36 2.03 2.57 3.10 3.86 -1.57 -1.79 1.58 1.34 2.41 2.89 4.07 -2.51 -0.35 0.43 0.67 2.59 3.08 4.15

Bayesian Analysis Assignment Sheet 3 Submission deadline: 8pm Monday 6th April Please name your submission using own name, e.g. Jane Doe e3.pdf Produce a short report (in either word, open office or pdf format) which answers the following questions and includes all used JAGS and R code and appropriate plots. You may scan handwritten solutions to the non- code based parts as part of your answers and add these to your document but it should be straightforward to answer all parts without the explicit inclusion of mathematical equations. Exercise 1. Look at the dataset hepatitis.dat. The data are yij as the log anti-HB titre (the amount of surface antibody) for the jth observation on the ith infant. There are n = 52 infants and m = 7 observations on each. Observations are taken for each infant at 7 set times after the vaccination was administered. These are set at t = 1.0, 2.5, 5.0, 7.0, 10.0, 15.0, 20.0 minutes. A suitable model is expected to use log time x = log(t) as an explanatory variable so that the likelihood for the model you will use is given by: yij ∼ N(µij , τ) where µij = αi + βi (xj − x̄) The priors are given by: αi ∼ N(α0, τα) βi ∼ N(β0, τβ) Finally, you will need to set uniform priors for α0, β0 (use [−100, 100] as limits) and set Jeffreys’ priors for τα, τβ . Hint: Recall that τ ∼ Gamma(10−3, 10−6) can be used as the Jeffreys’ prior on a parameter τ i.e. p(τ) ∝ 1τ . (a) Write JAGS code to fit this hierarchical linear model to the Hepatitis data set in hepatitis.dat. [10] (b) Give an estimate of the mean slope and mean intercept including a 95% credible interval. [5] Exercise 2. Look at the swiss dataset in R (try ?swiss to look at a description of the data). You will fit a Bayesian Linear Regression model for Fertility as dependent on the other 5 variables. i.e. Fertilityi ∼ Normal(µi, τ) with precision τ and mean µi = β1 + β2Agriculturei + β3Examinationi + β4Educationi + β5Catholici + β6Infant.Mortalityi (a) If the precision of the likelihood is taken to be τ = 0.02 and flat priors are used on all β then the likelihood can be written as y|X,β ∼ N(Xβ, φI) where β a vector of regression coefficients, and I the identity matrix, φ = 1/τ , and X is a matrix of size 47 × 6 with the first column all 1s and the other 5 columns equal to the independent variables. Show that the posterior mean for β equals (66.92,−0.17,−0.26,−0.87, 0.1, 1.08) correct to two decimal places. Hints: multiply matrices and vectors using %*%, find transposes of matrices using t(), use solve() to invert a matrix. For example the posterior inverse-covariance matrix can be calculated using Q=t(X)%*%X and then S=solve(Q) to find the covariance matrix (referred to as Σ in the notes). [5] (b) Fit the model using JAGS and uniform [−100, 100] priors on the regression coefficients and 50, 000 MCMC iterations. Is the posterior mean you get the same as you found in part (a)? [10] (c) Now examine the marginal distributions for the 6 regression coefficients. The jth marginal of a Multi- variate Normal is simply a Normal distribution with mean µj and variance Σjj . Create a plot for each coefficient showing the sample marginal of the posterior and the theoretical marginal. [10] (d) Now use a new .model file that sets τ to unknown and use a reference prior p(τ) ∝ 1τ . What happens to the marginal posteriors for the regression coefficients? Why? Hint: calculate the percentage change in posterior marginal standard deviation for each regression coefficient. [10]

## Related Questions

Similar orders to I need help with a bayesian analysis assignment
9
Views
0
Online statistics test 7 questions 3hr time limit
No Webcam. 7 questions statistics test with a 3hr time limit once you start. There is a test 3 study guide and practice questions under modules. Everything is under the last weeks modules in the statistics class....
10
Views
0
First Year Statistics Exam Help
I am in a first-year university business statistics class and have an exam on Tuesday, April 20th at 3 P.M EST (GMT-4) and would like somebody to answer the questions for me. We would call on a platform such as discord and I will share my screen, you then ...
47
Views
0
Excel Spreadsheet Assignment with questions
The questions and tasks are in the excel spreadsheet tabs. The data is given, there are questions and histogram to complete. the tabs are below on the excel file...
35
Views
0