Assignment 5
1 General information
This assignment is related to Lecture 5 and Chapters 10 and 11.
The maximum amount of points from this assignment is 6.
We have prepared a *quarto template specific to this assignment (html, qmd, pdf)** to help you get started.
If you are not using JupyterHub (which has all the needed packages pre-installed), and want to make the assignment on your own computer, you may use a docker container that includes all the necessary software packages, too.
Reading instructions:
Grading instructions:
The grading will be done in peergrade. All grading questions and evaluations for this assignment are contained within this document in the collapsible Rubric blocks.
For posterior statistics of interest, only report digits that are not completely random based on the Monte Carlo standard error (MCSE).
Example: If you estimate \(E(\mu) \approx 1.234\) with MCSE(\(E(\mu)\)) = 0.01, then the true expectation is likely to be between \(1.204\) and \(1.264\), it makes sense to report \(E(\mu) \approx 1.2\).
See Lecture video 4.1, the chapter notes, and a case study for more information.
- The recommended tool in this course is R (with the IDE RStudio).
- Instead of installing R and RStudio on you own computer, see how to use R and RStudio remotely.
- If you want to install R and RStudio locally, download R and RStudio.
- There are tons of tutorials, videos and introductions to R and RStudio online. You can find some initial hints from RStudio Education pages.
- When working with R, we recommend writing the report using
quarto
and the provided template. The template includes the formatting instructions and how to include code and figures. - Instead of
quarto
, you can use other software to make the PDF report, but the the same instructions for formatting should be used. - Report all results in a single, anonymous *.pdf -file and submit it in peergrade.io.
- The course has its own R package
aaltobda
with data and functionality to simplify coding. The package is pre-installed in JupyterHub. To install the package on your own system, run the following code (upgrade="never" skips question about updating other packages):
install.packages("aaltobda", repos = c("https://avehtari.github.io/BDA_course_Aalto/", getOption("repos")))
- Many of the exercises can be checked automatically using the R package
markmyassignment
(pre-installed in JupyterHub). Information on how to install and use the package can be found in themarkmyassignment
documentation. There is no need to includemarkmyassignment
results in the report. - Recommended additional self study exercises for each chapter in BDA3 are listed in the course web page. These will help to gain deeper understanding of the topic.
- Common questions and answers regarding installation and technical problems can be found in Frequently Asked Questions (FAQ).
- Deadlines for all assignments can be found on the course web page and in Peergrade. You can set email alerts for the deadlines in Peergrade settings.
- You are allowed to discuss assignments with your friends, but it is not allowed to copy solutions directly from other students or from internet.
- You can copy, e.g., plotting code from the course demos, but really try to solve the actual assignment problems with your own code and explanations.
- Do not share your answers publicly.
- Do not copy answers from the internet or from previous years. We compare the answers to the answers from previous years and to the answers from other students this year.
- Use of AI is allowed on the course, but the most of the work needs to by the student, and you need to report whether you used AI and in which way you used them (See points 5 and 6 in Aalto guidelines for use of AI in teaching).
- All suspected plagiarism will be reported and investigated. See more about the Aalto University Code of Academic Integrity and Handling Violations Thereof.
- Do not submit empty PDFs, almost empty PDFs, copy of the questions, nonsense generated by yourself or AI, as these are just harming the other students as they can’t do peergrading for the empty or nonsense submissions. Violations of this rule will be reported and investigated in the same way was plagiarism.
- If you have any suggestions or improvements to the course material, please post in the course chat feedback channel, create an issue, or submit a pull request to the public repository!
2 Generalized linear model: Bioassay model with Metropolis algorithm
Metropolis algorithm: Replicate the computations for the bioassay example of BDA3 Section 3.7 using the Metropolis algorithm. The Metropolis algorithm is described in BDA3 Chapter 11.2. More information on the bioassay data can be found in Section 3.7 in BDA3, and in Chapter 3 notes.
Compute with log-densities. Reasons are explained on BDA3 page 261 and Lecture video 4.1. Remember that \(p_1/p_0=\exp(\log(p_1)-\log(p_0))\). For your convenience we have provided functions that will evaluate the log-likelihood for given \(\alpha\) and \(\beta\) (see bioassaylp()
in the aaltobda
package). Notice that you still need to add the prior yourself and remember the unnormalized log posterior is simply the sum of log-likelihood and log-prior. For evaluating the log of the Gaussian prior you can use the function dmvnorm
from package aaltobda
.
Use a simple (normal) proposal distribution. Example proposals are \(\alpha^* \sim N(\alpha_{t-1}, \sigma = 1)\) and \(\beta^* \sim N(\beta_{t-1}, \sigma = 5)\). There is no need to try to find optimal proposal but test some different values for the jump scale (\(\sigma\)). Remember to report the one you used. Efficient proposals are discussed in BDA3 p. 295–297 (not part of the course). In real-life a pre-run could be made with an automatic adaptive control to adapt the proposal distribution.