-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
390 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
title: "EEEB UN3005/GR5005 \nLab - Week 05 - 24 and 26 February 2020" | ||
author: "USE YOUR NAME HERE" | ||
output: pdf_document | ||
fontsize: 12pt | ||
--- | ||
|
||
```{r setup, include = FALSE} | ||
knitr::opts_chunk$set(echo = TRUE) | ||
library(rethinking) | ||
``` | ||
|
||
|
||
# Statistical Distributions and Summary Statistics | ||
|
||
|
||
## Exercise 1: Grid Approximation, Our Old Friend | ||
|
||
Imagine that the globe tossing example from the *Statistical Rethinking* text and class resulted in 8 water observations out of 15 globe tosses. | ||
|
||
With this set of data, use grid approximation (with 101 grid points) to construct the posterior for *p* (the probability of water). Assume a flat prior. | ||
|
||
Plot the posterior distribution. | ||
|
||
```{r} | ||
``` | ||
|
||
|
||
## Exercise 2: Sampling From a Grid-Approximate Posterior | ||
|
||
Now generate 10,000 samples from the posterior distribution of *p*. Call these samples `post.samples`. Visualize `post.samples` using the `dens()` function. | ||
|
||
For your own understanding, re-run your sampling and plotting code multiple times to observe the effects of sampling variation. | ||
|
||
```{r} | ||
``` | ||
|
||
|
||
## Exercise 3: Summarizing Samples | ||
|
||
Return the mean, median, and mode (using `chainmode()`) of `post.samples`. Then calculate the 80%, 90%, and 99% highest posterior density intervals of `post.samples`. | ||
|
||
```{r} | ||
``` | ||
|
||
|
||
## Exercise 4: Model Predictions | ||
|
||
Using `post.samples`, generate 10,000 simulated model predictions (you can call these `preds`) for a binomial trial of size 15. Visualize the model predictions using the `simplehist()` function. | ||
|
||
Based on these posterior predictions, what is the probability of observing 8 waters in 15 globe tosses? | ||
|
||
```{r} | ||
``` | ||
|
||
|
||
## Exercise 5: More Model Predictions | ||
|
||
Using the *same* posterior samples (i.e., `post.samples`), generate 10,000 posterior predictions for a binomial trial of size 9. | ||
|
||
Using these new predictions, calculate the posterior probability of observing 8 waters in 9 tosses. | ||
|
||
```{r} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.