Description
General information
• The recommended tool in this course is R (with the IDE R-Studio). You can download R here and R-Studio here. There are tons of tutorials, videos and introductions to R and R-Studio online. You can find some initial hints here.
• You can write the report with your preferred software, but the outline of the report should follow the instruction in the R markdown template that can be found here.
• Report all results in a single, anonymous *.pdf -file and return it to peergrade.io.
• The course has its own R package with data and functionality to simplify coding. To install the package just run the following:
1. install.packages(“remotes”)
2. remotes::install_github(“avehtari/BDA_course_Aalto”, subdir = “rpackage”)
• Many of the exercises can be checked automatically using the R package markmyassignment. Information on how to install and use the package can be found here. • Additional self study exercises and solutions for each chapter in BDA3 can be found here.
• We collect common questions regarding installation and technical problems in a course Frequently Asked Questions (FAQ). This can be found here. • If you have any suggestions or improvements to the course material, please feel free to create an issue or submit a pull request to the public repository!!
Information on this assignment
This exercise is related to Chapters 10 and 11. The maximum amount of points from this assignment is 6.
Reading instructions: Chapter 10 and 11 in BDA3, see reading instructions here and here.
Grading instructions: The grading will be done in peergrade. All grading questions and evaluations for assignment 6 can be found here
Reporting accuracy: As many significant digits as justified by the Monte Carlo error and posterior accuracy.
Installing and using rstan: See the Stan demos on how to use Stan from R. The Aalto Ubuntu desktops have the necessary libraries installed so there should be no need to install anything. To install Stan on your laptop, see the instructions below.
Stan manual can be found at http://mc-stan.org/documentation/. From this website, you can also find a lot of other useful material about Stan.
1. Generalized linear model: Bioassay with Stan (6 points)
Replicate the computations for the bioassay example of section 3.7 (BDA3) using Stan.
1. Write down the model for the bioassay data in Stan syntax. More information on the bioassay data can be found in Section 3.7 of the course book and in chapter 3 reading instructions here. To get access to data, use the following code:
> library(aaltobda)
> data(“bioassay”)
Use the Gaussian prior as in Assignment 4 and 5, that is
N(µ0,Σ0), where µ and .
Hint! You will need stan functions multi_normal and binomial_logit for implementing the prior and observation model, respectively. In Stan code, it is easiest to declare a variable (say theta) which is a two-element vector so that the first value denotes α and latter one β. This is because the multi_normal function that you need for implementing the prior requires a vector as an input.
2. Use Rˆ for convergence analysis. You can either use Eq. (11.4) in BDA3 or the later version that can be found here. You should specify which Rˆ you used. In R the best choice is to use function Rhat from package rstan. Note that Stan gives you these values automatically; in R you can simply type print(fit), where fit is the fit object returned by Stan’s sampling function. Report the Rˆ values both for α and β and discuss the convergence of the chains. This means that you should briefly explain how to interpret the obtained Rˆ values.
3. Plot the draws for α and β (scatter plot) and include this plot in your report. You can compare the results to Figure 3.3b in BDA3 to verify that your code gives sensible results. Notice though that the results in Figure 3.3b are generated from posterior with a uniform prior, so even when your algorithm works perfectly, the results will look slightly different (although fairly similar).




Reviews
There are no reviews yet.