Every team member should go to the course GitHub organization and locate their lab09 repository, which should have the prefix lab09. Copy the URL of the repository and clone the remote repo in RStudio.
As you work on this lab, merge conflicts may arise. Refer back to Lab #05 for how to fix them. You and your team are free to divide up the work how you think is best. However, everyone should understand all code in the lab’s final submission.
This lab will use the packages below.
library(tidyverse)
library(broom)
The 2018 Congressional election saw a near-record number of retirements. In this lab, you will work with data from the 2018 election to investigate retirement.
The variables in this dataset are:
retiring
: a dummy variable indicating whether the representative retired in 2018. This includes representatives who left politics, those who sought higher office, and some who resigned early.stcd
: an ID number for the congressional district. Districts are listed in alphabetic order (101 is Alabama’s first district).dpres
: the two-party percentage of vote received by Hillary Clinton (the Democratic nominee for President) in the district in the 2016 Presidential election. (Third party vote has been eliminated here, this is Democratic vote / (Democratic vote + Republican vote).)gopseat
: a dummy variable indicating whether the seat was held by a Republican prior to the 2018 election.age
: The age of the representative at the end of 2018.Four of the seats have missing values for retiring
, gopseat
, and age
. These are seats that are new or the representative died. Before beginning the exercises, use filter()
to overwrite retirement
so there is no missing data.
What do each of these coefficients mean? Discuss what each means in terms of odds ratios.
Create a predicted probability plot showing the effect of presidential vote for both Democrats and Republicans. Set age at 60 when creating this plot. Comment on what you observe.
The current representative for North Carolina’s 4th district is Democrat David Price, who was a Duke Public Policy and Political Science Professor before being elected to Congress. In 2018, Price was 78 years old and Hillary Clinton received 70.75% of the vote in his district four years earlier. According to the model, what was the probability that Price would retire in 2018?
Based on our model, did any member of Congress have over a 50% chance of retiring in 2018? Which district’s representative was given the highest probability of a retirement and what was that probability? Did they actually retire? (Hint: augment()
is very useful for this problem.)