Bentley - Project
Bentley - Project
- Part 1 - Introduction
- Part 2 - Data
- Part 3 - Exploratory data analysis
- Part 4 - Inference
- Have there been significant differences in the amount of presidential support from the House and Senate?
- Is there more successful legislative activity when Congress supports the President?
- Is there more successful legislative activity when Congress leans more to the right or to the left?
- Is there more legislative success under a Republican or Democratic President
- Part 5 - Conclusion
- Appendix
Part 1 - Introduction
Like many people I have become increasingly interested in how the political dynamics between the parties impacts the ability of our government to perform its functions. While my hope is to explore the tipping points around major changes to legislative rules for this project I will focus on these questions:
Have there been significant differences in the amount of presidential support from the House and Senate?
Is there more successful legislative activity when Congress supports the President?
Is there more successful legislative activity when Congress leans more to the right or to the left?
Is there more successful legislative activity under a Republican or Democratic President?
Part 2 - Data
Sources
There are a number of sources that deal with these questions. I found the following three to be the most interesting:
VoteView has the most interesting data to work with, particularly:
- President Support Score which reflects the fraction of times that each Congress voted to support the president’s position across all votes on which the president’s position can be inferred.
pss <- read.csv("https://raw.githubusercontent.com/ajbentley/cuny_ms_ds/master/606/presidential_support_summary.csv", header = TRUE, stringsAsFactors = FALSE)
knitr::kable(head(pss), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | house | senate | avg |
|---|---|---|---|
| 1955 | 57.2 | 73.4 | 65.3 |
| 1956 | 63.0 | 60.2 | 61.6 |
| 1957 | 53.2 | 67.4 | 60.3 |
| 1958 | 59.1 | 61.9 | 60.5 |
| 1959 | 52.0 | 54.3 | 53.2 |
| 1960 | 51.1 | 57.0 | 54.1 |
- NOMINATE which measures the political leanings of individuals or bodies on two liberal-conservative dimensions: economic and social.
I’ll be bringing in two files that feature NOMINATE info. The first records every Roll Call Vote (RCV) Congress has made.
rcv <- read.csv("https://raw.githubusercontent.com/ajbentley/cuny_ms_ds/master/606/rollcalls.csv", header = TRUE, stringsAsFactors = FALSE)
knitr::kable(head(rcv), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| order | congress | chamber | rollnumber | date | yea.nay | yea_count | nay_count | nominate_mid_1 | nominate_mid_2 | nominate_spread_1 | nominate_spread_2 | nominate_log_likelihood | Success | vote_result | vote_desc | vote_question | dtl_desc |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 12217 | 108 | House | 277 | 6/16/03 | 378 | 378 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | Passed | “Carl T. Curtis National Park Service Midwest Regional Headquarters Building” | On Motion to Suspend the Rules and Pass | |
| 12048 | 108 | House | 108 | 4/7/03 | 383 | 383 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | Passed | “Dr. Roswell N. Beck Post Office Building” Designation Act | On Motion to Suspend the Rules and Pass | |
| 23100 | 113 | House | 459 | 9/17/13 | 405 | 407 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | Passed | “E. Clay Shaw, Jr. Missing Children’s Assistance Reauthorization Act of 2013” | On Motion to Suspend the Rules and Pass, as Amended | |
| 19824 | 111 | House | 1614 | 12/15/10 | 405 | 405 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | Passed | “Harry T. and Harriette Moore Post Office” | On Motion to Suspend the Rules and Pass | |
| 12050 | 108 | House | 110 | 4/7/03 | 380 | 380 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | Passed | “Norman Shumway Post Office Building” Designation Act | On Motion to Suspend the Rules and Pass, as Amended | |
| 19827 | 111 | House | 1617 | 12/15/10 | 399 | 399 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | Passed | “Private Isaac T. Cortes Post Office” | On Motion to Suspend the Rules and Pass |
The second NOMINATE file records the NOMINATE standing of every president and member of congress.
members <- read.csv("https://raw.githubusercontent.com/ajbentley/cuny_ms_ds/master/606/HSall_members.csv", header = TRUE, stringsAsFactors = FALSE)
knitr::kable(head(members), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| congress | chamber | icpsr | state_icpsr | district_code | state_abbrev | party_code | occupancy | last_means | bioname | bioguide_id | born | died | nominate_dim1 | nominate_dim2 | nominate_log_likelihood | nominate_geo_mean_probability | nominate_number_of_votes | nominate_number_of_errors | conditional | nokken_poole_dim1 | nokken_poole_dim2 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | President | 99869 | 99 | 0 | USA | 5000 | NA | NA | WASHINGTON, George | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | NA | |
| 1 | House | 4766 | 1 | 98 | CT | 5000 | 0 | 1 | HUNTINGTON, Benjamin | H000995 | 1736 | 1800 | 0.639 | 0.304 | -29.04670 | 0.708 | 84 | 12 | NA | 0.649 | 0.229 |
| 1 | House | 8457 | 1 | 98 | CT | 5000 | 0 | 1 | SHERMAN, Roger | S000349 | 1721 | 1793 | 0.589 | 0.307 | -40.59580 | 0.684 | 107 | 18 | NA | 0.614 | 0.298 |
| 1 | House | 9062 | 1 | 98 | CT | 5000 | 0 | 1 | STURGES, Jonathan | S001047 | 1740 | 1819 | 0.531 | 0.448 | -25.87361 | 0.724 | 80 | 13 | NA | 0.573 | 0.529 |
| 1 | House | 9489 | 1 | 98 | CT | 5000 | 0 | 1 | TRUMBULL, Jonathan, Jr. | T000389 | 1740 | 1809 | 0.692 | 0.246 | -30.47113 | 0.750 | 106 | 11 | NA | 0.749 | 0.166 |
| 1 | House | 9706 | 1 | 98 | CT | 5000 | 0 | 1 | WADSWORTH, Jeremiah | W000013 | 1743 | 1804 | 0.738 | 0.206 | -16.56694 | 0.825 | 86 | 5 | NA | 0.770 | 0.146 |
Transformations
Roll Call Votes
I’m going to be looking at things annually later on so I’m going to need to group this information by year.
Create fail and success rates by year
The below chunk sometimes ran fine. Sometimes not. Rather than toy with it I’m just going to bring in a saved version.
# creating fails and success by year
# creating new df with just year and success counts
# rcv_annual_successes <- select(rcv, c("year", "Success")) %>%
# group_by(year) %>%
# count(rcv_annual_successes$Success)
# rcv_ann_succ <- rcv_annual_successes
# rcv_ann_succ$Success <- as.factor(rcv_ann_succ$Success)
# rcv_ann_succ$Success <- revalue(rcv_ann_succ$Success, c("0" = "Fail", "1" = "Succeed"))
# rcv_ann_succ1 <- spread(rcv_ann_succ, Success, freq)
# rcv_ann_succ1$succ.to.fail.ratio <- rcv_ann_succ1$Succeed / rcv_ann_succ1$Fail
# write.csv(rcv_ann_succ1, "rcv_ann_succ1.csv")rcv_ann_succ1 <- read.csv("https://raw.githubusercontent.com/ajbentley/cuny_ms_ds/master/606/rcv_ann_succ1.csv", header = TRUE, stringsAsFactors = FALSE) %>%
select(-"X")
rcv_ann_succ1$year <- as.character(rcv_ann_succ1$year)Creating RCV averages by year
rcv_annual_nominate <- select(rcv, c("year", "nominate_mid_1", "nominate_mid_2")) %>%
group_by(year)%>%
summarise_all(funs(mean))
colnames(rcv_annual_nominate) <- c("year", "congress_mid_dim_1", "congress_mid_dim_2")Bringing the data together
Individuals NOMINATE
What we really need from this are President rows and the nominate_geo_mean_probability column. Because they don’t have scores we’ll just skip Washington and Adams.
# create new df that is just the President and his nom score
presidents <- filter(members, chamber == "President") %>%
select("bioname", "nominate_geo_mean_probability")
# rename columns
colnames(presidents) <- c("President", "NGMP")
# change nom score to character type
presidents$NGMP <- as.character(presidents$NGMP)
# exclude Washington / Adams.
pns <-slice(presidents, 7:123)
# fill down the nom score where there is a repeated line
pns$NGMP <- na.locf(pns$NGMP)Presidents
This is a data frame of Presidents, including dates taking and leaving office
pl <- read.csv("https://gist.githubusercontent.com/namuol/2657233/raw/74135b2637e624848c163759be9cd14ae33f5153/presidents.csv", header = TRUE, stringsAsFactors = FALSE)
knitr::kable(head(pl), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| Presidency | President | Wikipedia.Entry | Took.office | Left.office | Party | Portrait | Thumbnail | Home.State |
|---|---|---|---|---|---|---|---|---|
| 1 | George Washington | http://en.wikipedia.org/wiki/George_Washington | 30/04/1789 | 4/03/1797 | Independent | GeorgeWashington.jpg | thmb_GeorgeWashington.jpg | Virginia |
| 2 | John Adams | http://en.wikipedia.org/wiki/John_Adams | 4/03/1797 | 4/03/1801 | Federalist | JohnAdams.jpg | thmb_JohnAdams.jpg | Massachusetts |
| 3 | Thomas Jefferson | http://en.wikipedia.org/wiki/Thomas_Jefferson | 4/03/1801 | 4/03/1809 | Democratic-Republican | Thomasjefferson.gif | thmb_Thomasjefferson.gif | Virginia |
| 4 | James Madison | http://en.wikipedia.org/wiki/James_Madison | 4/03/1809 | 4/03/1817 | Democratic-Republican | JamesMadison.gif | thmb_JamesMadison.gif | Virginia |
| 5 | James Monroe | http://en.wikipedia.org/wiki/James_Monroe | 4/03/1817 | 4/03/1825 | Democratic-Republican | JamesMonroe.gif | thmb_JamesMonroe.gif | Virginia |
| 6 | John Quincy Adams | http://en.wikipedia.org/wiki/John_Quincy_Adams | 4/03/1825 | 4/03/1829 | Democratic-Republican/National Republican | JohnQuincyAdams.gif | thmb_JohnQuincyAdams.gif | Massachusetts |
Let’s pare this down to just the President’s name, party and year taking / leaving office.
# selecting desired columns only
pl2 <- select(pl, "President", "Party", "Took.office", "Left.office")
# converting N/A for Obama's last day to 2017/01/19
pl2[44,3] <- "20/01/2017"
# adding trump
trump <- c("Donald Trump", "Republican", "20/01/2017", "20/01/2020")
pl2 <- rbind(pl2, trump)
# create new cols for term start year and term end year
pl2$term.start.yr <- as.numeric(str_extract(pl2$Took.office, "[:digit:]{4}"))
pl2$term.end.yr <- as.numeric(str_extract(pl2$Left.office, "[:digit:]{4}"))
# subtacting one year from Left office so that there is no overlap between administrations.
pl2$term.end.yr <- pl2$term.end.yr - 1
knitr::kable(head(pl2), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| President | Party | Took.office | Left.office | term.start.yr | term.end.yr |
|---|---|---|---|---|---|
| George Washington | Independent | 30/04/1789 | 4/03/1797 | 1789 | 1796 |
| John Adams | Federalist | 4/03/1797 | 4/03/1801 | 1797 | 1800 |
| Thomas Jefferson | Democratic-Republican | 4/03/1801 | 4/03/1809 | 1801 | 1808 |
| James Madison | Democratic-Republican | 4/03/1809 | 4/03/1817 | 1809 | 1816 |
| James Monroe | Democratic-Republican | 4/03/1817 | 4/03/1825 | 1817 | 1824 |
| John Quincy Adams | Democratic-Republican/National Republican | 4/03/1825 | 4/03/1829 | 1825 | 1828 |
Need to make changes to the President names in pl2 and/or pns so that they can be matched up.
While I like the pl2 format better there are 45 rows there and 117 in pns.
pPn <- c("WASHINGTON, George", "ADAMS, John", unique(pns$President[1:50]), unique(pns$President[51:117]))
pl2$President <- pPnNow I can add specific years to the pns data frame.
The pss (Presidential Support Score) data frame is by year starting in 1955, Eisenhower’s third year so we just need to add who the President was in each year.
# create new df with presidents from Eisenhower on
pl3 <- pl2[34:45, 1:6]
# create new df with years we're looking for and assign it a column name of yr
year <- data.frame(seq(1953, 2019))
colnames(year) <- "year"
# create column in pl3 with the same information but new name of start year (to match yr df.
pl3$year <- pl3$term.start.yr
# join pl3 and year
pres_year <- left_join(year, pl3, by = "year")
knitr::kable(head(pres_year), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | President | Party | Took.office | Left.office | term.start.yr | term.end.yr |
|---|---|---|---|---|---|---|
| 1953 | EISENHOWER, Dwight David | Republican | 20/01/1953 | 20/01/1961 | 1953 | 1960 |
| 1954 | NA | NA | NA | NA | NA | NA |
| 1955 | NA | NA | NA | NA | NA | NA |
| 1956 | NA | NA | NA | NA | NA | NA |
| 1957 | NA | NA | NA | NA | NA | NA |
| 1958 | NA | NA | NA | NA | NA | NA |
We now have a df with empty spaces between each president’s year so we need to fill those in. In the same chunk we’ll cut the df back to just the year and president
# fill down presidents name and party
pres_year$President <- na.locf(pres_year$President)
pres_year$Party <- na.locf(pres_year$Party)
# keep just the two columns needed
pres_yr <- pres_year[1:67, 1:3]
knitr::kable(head(pres_yr), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | President | Party |
|---|---|---|
| 1953 | EISENHOWER, Dwight David | Republican |
| 1954 | EISENHOWER, Dwight David | Republican |
| 1955 | EISENHOWER, Dwight David | Republican |
| 1956 | EISENHOWER, Dwight David | Republican |
| 1957 | EISENHOWER, Dwight David | Republican |
| 1958 | EISENHOWER, Dwight David | Republican |
We can now attach the President’s name to the pss. We’ll also have to drop the first two years of Eisenhower’s term, the last two of Obama’s, and all of Trump’s.
pss <- left_join(pres_yr, pss, by = "year")
df <- pss[3:62, 1:6]
knitr::kable(head(df), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | President | Party | house | senate | avg | |
|---|---|---|---|---|---|---|
| 3 | 1955 | EISENHOWER, Dwight David | Republican | 57.2 | 73.4 | 65.3 |
| 4 | 1956 | EISENHOWER, Dwight David | Republican | 63.0 | 60.2 | 61.6 |
| 5 | 1957 | EISENHOWER, Dwight David | Republican | 53.2 | 67.4 | 60.3 |
| 6 | 1958 | EISENHOWER, Dwight David | Republican | 59.1 | 61.9 | 60.5 |
| 7 | 1959 | EISENHOWER, Dwight David | Republican | 52.0 | 54.3 | 53.2 |
| 8 | 1960 | EISENHOWER, Dwight David | Republican | 51.1 | 57.0 | 54.1 |
The last thing to bring in the nominate data.
rcv2$year <- as.numeric(rcv2$year)
df <- left_join(df, rcv2, by = "year")
colnames(df) <- c("year", "President", "Party", "House.PSS", "Senate.PSS", "Avg.PSS", "Leg.Fail", "Leg.Succ", "Leg.Succ.to.Fail.Ratio", "Cong.Dim1", "Cong.Dim2")
knitr::kable(head(df), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | President | Party | House.PSS | Senate.PSS | Avg.PSS | Leg.Fail | Leg.Succ | Leg.Succ.to.Fail.Ratio | Cong.Dim1 | Cong.Dim2 |
|---|---|---|---|---|---|---|---|---|---|---|
| 1955 | EISENHOWER, Dwight David | Republican | 57.2 | 73.4 | 65.3 | NA | NA | NA | NA | NA |
| 1956 | EISENHOWER, Dwight David | Republican | 63.0 | 60.2 | 61.6 | NA | NA | NA | NA | NA |
| 1957 | EISENHOWER, Dwight David | Republican | 53.2 | 67.4 | 60.3 | NA | NA | NA | NA | NA |
| 1958 | EISENHOWER, Dwight David | Republican | 59.1 | 61.9 | 60.5 | NA | NA | NA | NA | NA |
| 1959 | EISENHOWER, Dwight David | Republican | 52.0 | 54.3 | 53.2 | NA | NA | NA | NA | NA |
| 1960 | EISENHOWER, Dwight David | Republican | 51.1 | 57.0 | 54.1 | NA | NA | NA | NA | NA |
Part 3 - Exploratory data analysis
President support score
This file has four pieces of information:
- Year
- Presidential Support Score (PSS) of the House of Representatives
- PSS of the Senate
- Average of the two PSS scores
knitr::kable(head(pss), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | President | Party | house | senate | avg |
|---|---|---|---|---|---|
| 1953 | EISENHOWER, Dwight David | Republican | NA | NA | NA |
| 1954 | EISENHOWER, Dwight David | Republican | NA | NA | NA |
| 1955 | EISENHOWER, Dwight David | Republican | 57.2 | 73.4 | 65.3 |
| 1956 | EISENHOWER, Dwight David | Republican | 63.0 | 60.2 | 61.6 |
| 1957 | EISENHOWER, Dwight David | Republican | 53.2 | 67.4 | 60.3 |
| 1958 | EISENHOWER, Dwight David | Republican | 59.1 | 61.9 | 60.5 |
What are the summary statistics for each column?
## year President Party house
## Min. :1953 Length:67 Length:67 Min. :36.50
## 1st Qu.:1970 Class :character Class :character 1st Qu.:47.75
## Median :1986 Mode :character Mode :character Median :53.55
## Mean :1986 Mean :52.81
## 3rd Qu.:2002 3rd Qu.:58.88
## Max. :2018 Max. :64.50
## NA's :7
## senate avg
## Min. :46.50 Min. :45.10
## 1st Qu.:57.42 1st Qu.:53.02
## Median :61.30 Median :58.25
## Mean :62.86 Mean :57.86
## 3rd Qu.:67.53 3rd Qu.:61.95
## Max. :81.70 Max. :70.20
## NA's :7 NA's :7
Generally speaking the Senate has been on the side of the President more often than the House has.
Let’s take a look at the distributions of each.
par(mfrow = c(2, 2))
set.seed(23)
hist(pss$house, breaks = 8)
hist(pss$senate, breaks = 8)
housepss_means <- rep(pss$house, 50)
for(i in pss$house){
hpss_means <- sample(pss$house, 15, replace = FALSE)
housepss_means[i] <- mean(hpss_means)
}
hist(housepss_means, breaks = 8)
senatepss_means <- rep(pss$senate, 50)
for(i in pss$senate){
spss_means <- sample(pss$senate, 15, replace = FALSE)
senatepss_means[i] <- mean(spss_means)
}
hist(senatepss_means, breaks = 8)The Senate looks like it is fairly normal (with a slight right skew) both in its overall distribution and in the distribution of its means.
The House, on the other hand, looks somewhat left-skewed. This is contrary to what we saw in the means as it suggests that the Presidential Support Score is more often higher in the House.
It’s always frustrating when two analyses conflict with each other but we’ll look at some inferences later that might clear things up.
Has this changed over time?
This is an interactive chart: hover over a data point to see the Senate and House PSS as well as the year.
Administrations start in the year after the election so while so while Reagan was elected in 1980 his administration started in 1981.
a <- list(
autotick = FALSE,
ticks = "outside",
tick0 = 1961,
dtick = 4
)
yt <- list(title = "Presidential Support Score")
sby_tl <- plot_ly(pss, x = ~year, y = ~house, name = "House PSS", type = 'scatter', mode = 'lines') %>%
add_trace(y = ~senate, name = "Senate PSS", mode = 'lines+markers') %>%
layout(xaxis=a, yaxis = yt, hovermode = 'compare')
sby_tlWhile the House has fairly consistently been less in line with the President the disparity has at times been far greater than ever before in recent years.
Let’s take a look at that difference over time.
pss$diff <- abs(pss$house - pss$senate)
pss_diff_tl <- plot_ly(pss, x = ~year, y = ~diff, name = "PSS Difference", type = 'scatter', mode = 'lines')
pss_diff_tlWow…I really wasn’t expecting the visual to be so stark in the rise in the difference between the two bodies.
- Prior to 1981 (Reagan’s first year) the average difference was 4.9 points.
- From 1981 - 1992 (Reagan and Bush 1) the average difference was 13.3 points.
- From 1993 - 2000 (Clinton) the average difference was 10.0 points.
- From 2001 - 2008 (Bush 2) the average difference was 17.0 points.
- From 2009 - 2012 (Obama’s first term) the average difference was 19.2 points.
- From 2013 - 2014 (the latest year available / Obama’s first term) the average difference was 28.9 points.
Since 1970 there have only been three periods when the two bodies were within 3 points of each other:
- 1970 - 1973 (most of Nixon’s term): average 0.5 difference.
- 1980 (Carter’s last year): 1.2 difference
- 1992 - 1993 (Bush 1’s last year and Clinton’s first year): average 1.2 difference (Bush 2.5 and Clinton 0.2, the closest the two bodies have ever been).
Fail / Success Rates and NOMINATE scores
These scores are only available in our transformed data from 1989 to 2014. In order to avoid having to deal with NA data I’ll just create a new df for those years.
mod_df <- df[35:60, 1:11]
knitr::kable(head(mod_df), format = "html") %>%
kable_styling(bootstrap_options = c("striped", "condensed"))| year | President | Party | House.PSS | Senate.PSS | Avg.PSS | Leg.Fail | Leg.Succ | Leg.Succ.to.Fail.Ratio | Cong.Dim1 | Cong.Dim2 | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 35 | 1989 | BUSH, George Herbert Walker | Republican | 50.5 | 67.9 | 59.2 | 50 | 148 | 2.960000 | -0.0011970 | -0.0117879 |
| 36 | 1990 | BUSH, George Herbert Walker | Republican | 40.0 | 52.2 | 46.1 | 219 | 492 | 2.246575 | 0.0936582 | 0.0173080 |
| 37 | 1991 | BUSH, George Herbert Walker | Republican | 48.2 | 58.7 | 53.5 | 190 | 407 | 2.142105 | 0.0736750 | -0.0154908 |
| 38 | 1992 | BUSH, George Herbert Walker | Republican | 53.4 | 50.9 | 52.2 | 214 | 431 | 2.014019 | 0.0697535 | 0.0101922 |
| 39 | 1993 | CLINTON, William Jefferson (Bill) | Democratic | 61.8 | 62.0 | 61.9 | 254 | 551 | 2.169291 | 0.0189925 | -0.0006124 |
| 40 | 1994 | CLINTON, William Jefferson (Bill) | Democratic | 63.2 | 67.2 | 65.2 | 253 | 478 | 1.889328 | 0.0201587 | -0.0283598 |
Let’s look at what the distributions of Legislative Success to Failure Rate look like.
par(mfrow = c(3, 3))
set.seed(23)
hist(mod_df$Leg.Succ.to.Fail.Ratio)
hist(mod_df$Leg.Succ)
hist(mod_df$Leg.Fail)
ratio_means <- rep(mod_df$Leg.Succ.to.Fail.Ratio, 50)
for(i in mod_df$Leg.Succ.to.Fail.Ratio){
rat_means <- sample(mod_df$Leg.Succ.to.Fail.Ratio, 15, replace = FALSE)
ratio_means[i] <- mean(rat_means)
}
hist(rat_means)
success_means <- rep(mod_df$Leg.Fail, 50)
for(i in mod_df$Leg.Succ){
s_means <- sample(mod_df$Leg.Succ, 15, replace = FALSE)
success_means[i] <- mean(s_means)
}
hist(s_means)
fail_means <- rep(mod_df$Leg.Fail, 50)
for(i in mod_df$Leg.Fail){
f_means <- sample(mod_df$Leg.Fail, 15, replace = FALSE)
fail_means[i] <- mean(f_means)
}
hist(f_means)It’s interesting that the actual distribution is more normal than the distribution of means. Not exactly sure how to process that.
Lastly, let’s look at how the NOMINATE dimensions are distributed
par(mfrow = c(2, 2))
set.seed(23)
hist(mod_df$Cong.Dim1)
hist(mod_df$Cong.Dim2)
dim1_means <- rep(mod_df$Cong.Dim1, 50)
for(i in mod_df$Cong.Dim1){
d1_means <- sample(mod_df$Cong.Dim1, 15, replace = FALSE)
dim1_means[i] <- mean(d1_means)
}
hist(d1_means)
dim2_means <- rep(mod_df$Cong.Dim2, 50)
for(i in mod_df$Cong.Dim2){
d2_means <- sample(mod_df$Cong.Dim2, 15, replace = FALSE)
dim2_means[i] <- mean(d2_means)
}
hist(d2_means)Let’s take a look at a plot of dim1 vs dim2.
Really no relationship between the two.
Has the amount of Legislative success or failure changed much?
a <- list(
autotick = FALSE,
ticks = "outside",
tick0 = 1961,
dtick = 4
)
yt <- list(title = " ")
suctrend <- plot_ly(mod_df, x = ~year, y = ~Leg.Fail, name = "Number of Legislative Failures", type = 'scatter', mode = 'lines') %>%
add_trace(y = ~Leg.Succ, name = "Number of Legislative Successes", mode = 'lines+markers') %>%
layout(yaxis = yt, hovermode = 'compare')
suctrendIn general both seem to be on the rise. How about the ratio of successes to failures?
rattrend <- plot_ly(mod_df, x = ~year, y = ~Leg.Succ.to.Fail.Ratio, name = "Legislative Success to Failure Ratio", type = 'scatter', mode = 'lines')
rattrendAll over the place!
Part 4 - Inference
Have there been significant differences in the amount of presidential support from the House and Senate?
Unfortunately the data we have don’t really allow us to test this. The distribution for the House PSS was left-skewing and even if we accept that 67 observations are enough to move forward those observations really aren’t independent since individuals are likely to appear in more than one year’s House or Senate.
Is there more successful legislative activity when Congress supports the President?
First let’s look at the summary data for successful legislative activity and for Presidential Support.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 148.0 480.8 544.0 560.5 634.5 983.0
## [1] 162.0038
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 46.10 54.33 59.15 59.34 65.28 70.20
## [1] 7.241938
## [1] -0.03354053
There is very little indication that the to metrics are related.
Is there more successful legislative activity when Congress leans more to the right or to the left?
Summary of NOMINATE Dimension 1
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.071406 -0.021727 0.009786 0.011494 0.043559 0.093658
## [1] 0.04777741
## [1] 0.3008356
Summary of NOMINATE Dimension 2
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.02836 0.00834 0.02327 0.04323 0.08367 0.16430
## [1] 0.05022251
## [1] 0.5013425
There doesn’t appear to be any strong connection between legislative success and NOMINATE scores.
Is there more legislative success under a Republican or Democratic President
H0 = The President’s Party has no influence on the legislative success ratio.
HA = The President’s Party has an influence on the legislative success ratio.
First we need to isolate the legislative successes by President’s Party
p <- c("Party", "Leg.Succ.to.Fail.Ratio")
pp_rat <- data.frame("Party" = c(mod_df$Party), "Leg.Succ.to.Fail.Ratio" = c(mod_df$Leg.Succ.to.Fail.Ratio))
hist(pp_rat$Leg.Succ.to.Fail.Ratio)There are only 26 records and the distribution is not clearly normally distributed, but we’re going to move forward anyway.
ppr_gop <- subset(pp_rat, Party == "Republican ")
ppr_dem <- subset(pp_rat, Party == "Democratic ")
ppr_gop## Party Leg.Succ.to.Fail.Ratio
## 1 Republican 2.960000
## 2 Republican 2.246575
## 3 Republican 2.142105
## 4 Republican 2.014019
## 13 Republican 2.077519
## 14 Republican 2.733333
## 15 Republican 1.574257
## 16 Republican 2.037500
## 17 Republican 1.693548
## 18 Republican 1.851449
## 19 Republican 1.686106
## 20 Republican 3.291262
## 21 Republican 2.297030
## 22 Republican 3.628866
## 23 Republican 1.115242
## 24 Republican 1.159705
## 25 Republican 1.830189
## 26 Republican 2.637860
## Party Leg.Succ.to.Fail.Ratio
## 5 Democratic 2.169291
## 6 Democratic 1.889328
## 7 Democratic 1.214418
## 8 Democratic 1.563492
## 9 Democratic 1.721154
## 10 Democratic 1.782443
## 11 Democratic 1.975352
## 12 Democratic 2.131579
pp_mtx <- data.frame("Party" = c("Democrat", "Republican"), "Mean.Ratio" = c(mean(ppr_dem$Leg.Succ.to.Fail.Ratio), mean(ppr_gop$Leg.Succ.to.Fail.Ratio)), "SD.Ratio" = c(sd(ppr_dem$Leg.Succ.to.Fail.Ratio), sd(ppr_gop$Leg.Succ.to.Fail.Ratio)))
pp_mtx## Party Mean.Ratio SD.Ratio
## 1 Democrat 1.805882 0.3139926
## 2 Republican 2.165365 0.6767097
Checking for 95% confidence
Difference in means = 2.165 - 1.81 = 0.335
n = 26
Df = 25
s1 = SD of Democratic = 0.314
s2 = SD of Republican = 0.677
A = \(\frac{s1^2}{n}\) = 0.004
B = \(\frac{s2^2}{n}\) = 0.018
SE = \(\sqrt{A+B}\) = 0.148
t*SE for 95% CI= 2.06
0.335 \(\pm\) 2.06 x 0.148 \(\Rightarrow\) CI = (-0.029, 0.641)
T = \(\frac{0.335}{0.306}\) = 1.09 \(\Rightarrow\) p > 0.10
As the p-value is more than the \(\alpha\) and as the CI passes through 0 we cannot reject the null hypothesis. It is possible that the President’s political party influences the amount of successful legislative action.
Part 5 - Conclusion
This is just the beginning of this analysis and there is much more detail to pursue. What we have learned is that the Senate probably has more support of the President historically than the House of Representatives does and that this difference is greater than ever.
We have found many metrics are unrelated, which is also useful (though less interesting).
Obviously knowing that the President’s party has an influence on legislative success begs more questions, but they will be part of my further work.
Appendix
NOMINATE works on two dimensions running from conservative to liberal. Dim 1 is economic and Dim 2 is social. It would be useful to have a single metric rather than to run everything on two. I’m going to see how well the two correlate and then just use one of them if the correlation is reasonable.
dimcheck1 <- members$nominate_dim1
dimcheck1 <- na.omit((dimcheck1))
dimcheck2 <- members$nominate_dim2
dimcheck2 <- na.omit((dimcheck2))
cor(dimcheck1, dimcheck2)## [1] -0.0668634
That is an awesome looking plot, but means that we definitely can’t use one or the other of the dimensions.
There are also two measures that are built off of the NOMINATE scores, a log-likelihood and a geometric mean probability. Maybe we can use one of those.
llcheck <- members$nominate_log_likelihood
llcheck <- na.omit((llcheck))
gmpcheck <- members$nominate_geo_mean_probability
gmpcheck <- na.omit((gmpcheck))
cor(llcheck, gmpcheck)## [1] 0.2886958
Another really cool plot that mostly tells us that these two metrics are almost totally dissimilar. I’ll just use the geo mean probability for now.