---
title: 'Stat 140: Inference for a Difference in Proportions'
author: "Evan Ray"
date: "November 20, 2017"
output:
  html_document:
    fig_height: 3
    fig_width: 5
  pdf_document:
    fig_height: 2.8
    fig_width: 6.5
  word_document:
    fig_height: 3
    fig_width: 5
---


```{r, include=FALSE}
# Don't delete this chunk if you are using the mosaic package
# This loads the mosaic and dplyr packages
require(mosaic)
require(tidyr)
options(digits=3)
```

```{r, include=FALSE}
# Some customization.  You can alter or delete as desired (if you know what you are doing).

# This changes the default colors in lattice plots.
trellis.par.set(theme=theme.mosaic())  
options(digits=4)

# knitr settings to control how R chunks work.
require(knitr)
opts_chunk$set(
  tidy=FALSE,     # display code as typed
  size="small"    # slightly smaller font for code
)
# This loads the mosaic data sets.  (Could be deleted if you are not using them.)
require(mosaicData)                
```

# Supreme Court Case *Buck v. Davis*

## Introduction

On October 5th, 2016, the United States Supreme Court heard arguments in the case of *Buck v. Davis*.  The case was about possible differences in how often appeals are granted in different circuits of the US Federal Appeals Courts (each circuit has its own court that makes decisions about appeals for a group of several states -- there's a map here: http://www.uscourts.gov/sites/default/files/u.s._federal_courts_circuit_map_1.pdf).  Here are some excerpts from an article at NPR about the case (you can read the full article at http://www.npr.org/2016/10/05/496769580/supreme-court-hears-indefensible-death-penalty-case-where-race-linked-to-violenc).

>``The Supreme Court heard arguments Wednesday in the case of Duane Buck, a convicted Texas murderer sentenced to die after a psychologist testified that he was more likely to commit violent crimes in the future because he is black.

>...

>When a similar case involving the same psychologist went to the Supreme Court in 2000, Texas conceded error. It also found six more cases in which Quijano [the psychologist] linked race to violence, and it pledged to allow all seven defendants to bring appeals for new sentencing hearings. The state delivered on that promise, except in Buck's case.

>Inside the Supreme Court chamber Wednesday, there seemed little doubt that would change. The question was how.

>Would the justices just say that the 5th Circuit Court of Appeals was wrong to deny Buck a sentencing appeal, a decision that would only affect Buck? **Or would they rule that the Fifth Circuit is an outlier in death penalty appeals and that its whole approach is wrong?**''

In order to make an argument that the Fifth Circuit has unreasonable requirements for allowing death penalty appeals, Buck's lawyers gathered data about the number of cases in each circuit where such appeals were denied over the last 5 years.  These can be found in Appendix F of the petition to take the case to the Supreme Court, here: http://www.scotusblog.com/wp-content/uploads/2016/05/Filed-Buck-Cert.-Pet._3-2.pdf.  I've summarized the data in the following table:

Circuit Number | Number of Appeal Requests | Number Denied
---------------|---------------------------|--------------
4th            |12                         |0
5th            |129                        |76
11th           |111                        |11

Let's use these data to compare the rates at which requests for appeals are denied by the 5th and 11th circuits.  How strong is the evidence for Justice Kagan's conclusion that "one of these two circuits is doing something wrong" -- i.e., the rate of appeal request denials is different in the two circuits?  (In the end, Buck was granted an appeal.)

## Check Assumptions

There are five (!) assumptions to check when comparing proportions from two groups:

#### 1. Two outcomes

SOLUTION:



#### 2. Same probability of success for all trials within each group (but the probability may be different in different groups)

SOLUTION:



#### 3. Independence

Within each group, the data should be based on results for independent individuals.  (If I know the outcome for one individual, does that change the probability of denial for another individual in the same circuit?)

SOLUTION:



#### 4. Independent Groups

The two groups we're comparing must be independent of each other.

SOLUTION:



#### 5. Sample Size

Within each group, is the sample size large enough?  We need to expect at least 10 "successes" and at least 10 "failures" within each group to perform inference based on a Normal distribution.

SOLUTION:



## Hypotheses

Regardless of your answers abou the assumptions, we will conduct a hypothesis test for the claim that the 5th and 11th circuits deny appeal requests at different rates.  Here, state the null and alternative hypotheses.  Define all symbols that you use (what are the parameters?)

SOLUTION:



## Computations in R

Use the prop.test function in R to calculate a p-value for the test and a 95% confidence interval.

SOLUTION:

```{r}
# Your code goes here

```


## Hypothesis Test

Conduct a hypothesis test for the claim that the 5th and 11th circuits deny appeal requests at different rates.  Use the $\alpha = 0.05$ significance level.  Based on the p-value you calculated above, make a decision and interpret it in context.

SOLUTION:



## Confidence Interval

Interpret the confidence interval you calculated above in the context of this problem.  What does it mean that you are "95% confident"?

SOLUTION:



## Limitations

The evidence here is pretty compelling.  Is it strong enough to bring to the Supreme Court?  Discuss at least one reason why the analysis we've done here does NOT definitively prove that there is a problem with the way the Fifth Circuit makes decisions about appeals.  What would you do to address those limitations if you were on Buck's legal team?

SOLUTION:

