Skip to content

Commit

Permalink
Adding week 07 lecture and lab
Browse files Browse the repository at this point in the history
  • Loading branch information
eveskew committed Mar 9, 2020
1 parent aede060 commit 55f2175
Show file tree
Hide file tree
Showing 3 changed files with 499 additions and 0 deletions.
66 changes: 66 additions & 0 deletions lab/lab_week_07.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: "EEEB UN3005/GR5005 \nLab - Week 07 - 09 and 11 March 2020"
author: "USE YOUR NAME HERE"
output: pdf_document
fontsize: 12pt
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(rethinking)
```


# Multiple Regression Models

For this week's lab, we'll be using data on foxes occupying urban England. You can access this data once you've loaded the `rethinking` package with the code `data(foxes)`. You can get a brief summary of all the variables contained in the dataset using `?foxes` or a data frame summary function of your choice.

Note, for all models you'll be asked to construct here, assume a prior of `dnorm(0, 10)` for all intercept and slope parameters and a prior of `dunif(0, 10)` for all standard deviation parameters. Furthermore, start values of 0 for all intercept and slope parameters and 5 for all standard deviation parameters should ensure good model fits throughout these exercises.


## Exercise 1: Linear Regression with Territory Size as a Predictor

Construct a linear regression model of fox body weight (`weight` variable) using territory size (`area` variable) as a predictor.

After fitting the model, use `precis()` to display the 90% PIs for all model parameters. Plot the results of this regression model by displaying the fox body weight and territory size variables and the MAP regression line.

What does this model suggest about the effect of territory size on fox body weight?

```{r}
```


## Exercise 2: Linear Regression with Group Size as a Predictor

Now, construct a linear regression model of fox body weight using fox group size (`groupsize` variable) as a predictor.

After fitting the model, use `precis()` to display the 90% PIs for all model parameters. Plot the results of this regression model by displaying the fox body weight and group size variables and the MAP regression line.

What does this model suggest about the effect of group size on fox body weight?

```{r}
```


## Exercise 3: Multiple Regression with Both Predictors

Now fit a multiple regression with fox body weight as the outcome and both territory size and group size as predictor variables.

What does this model say about the importance of each predictor variable? Why do you get different results than you got in the exercises above?

```{r}
```


## Exercise 4: Counterfactual Plots for a Multiple Regression

For the multiple regression model, generate counterfactual plots that show the mean trend line and the 95% HPDI of the mean for each predictor, holding the other predictor constant at its average value.

```{r}
```
Loading

0 comments on commit 55f2175

Please sign in to comment.