-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlab_week_11.Rmd
45 lines (24 loc) · 3.08 KB
/
lab_week_11.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
title: "EEEB UN3005/GR5005 \nLab - Week 11 - 06 and 08 April 2020"
author: "USE YOUR NAME HERE"
output: pdf_document
fontsize: 12pt
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(rethinking)
```
**Updated Lab Instructions Due to Remote Teaching:** Complete this assignment by writing code in the code chunks provided. If required, provide written explanations below the relevant code chunks. When complete, knit this document within RStudio to generate a PDF, and upload that document to CourseWorks by 5 pm on 09 April.
# Interactions
## Exercise 1: Multiple Regression with an Interaction Effect
Referencing the *Statistical Rethinking* text (see page 230 and relevant preceding code), reconstruct and fit the model `m7.9`. This model uses the `tulips` dataset. It models `blooms` as the outcome variable of interest, with centered versions of `water` and `shade`, as well as the interaction between them, as continuous predictor variables.
After fitting the model, use `precis()` to display the 97% PIs for all model parameter posteriors. Check to make sure your results generally align with what's shown in the book.
Finally, how do you interpret the intercept estimate in the context of this model? In other words, what portion of the data does the intercept estimate describe?
```{r}
```
## Exercise 2: Triptych Plots for Both Predictor Variables
In the *Statistical Rethinking* book, Figure 7.7 (page 234), you'll see a series of "triptych" plots. Pay particular attention to the bottom row of the panel, which shows model-based predictions (from model m7.9) for the effect of `shade.c` on `blooms`. Because the model includes multiple predictor variables, it makes sense to plot this relationship across multiple values of the other predictor (which is `water.c`, hence the series of three plots on the bottom row that have differing values of `water.c`). And because the model includes an interaction effect, the relationship between `shade.c` and `blooms` varies across those three plots.
To fully visualize the predictions from model m7.9, create two triptych plots. The first triptych plot should show the effect of `water.c` on `blooms`, plotted for three different values of `shade.c`. The second triptych plot should show the effect of `shade.c` on `blooms`, plotted for three different values of `water.c` (i.e., this second triptych plot should replicate exactly what you see in the bottom row of the book's Figure 7.7). Clearly, modifying the book's code will help you in generating this output. Feel free to visualize the 97% interval of the mean using lines (as in the book code) or using a shaded interval (as has been demonstrated in multiple places throughout the book and lecture code using the `shade()` function). Also note, you can plot these two triptych plots together neatly with some modification to your plotting window. See the book's R code 7.28 box for a hint as to how...
Using the plots to help with your interpretation, at which value(s) of shade is the effect of water most extreme? At which value(s) of water is the effect of shade most extreme?
```{r}
```