install required libraries

devtools::install_github("jbryer/DATA606")
## Skipping install of 'DATA606' from a github remote, the SHA1 (e12c7ab3) has not changed since last install.
##   Use `force = TRUE` to force installation

library(devtools) devtools::install_github(“jbryer/DATA606”)

load libaries

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.4     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.3     ✓ stringr 1.4.0
## ✓ readr   2.0.1     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(openintro)
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata

Stats scores. (2.33, p. 78) Below are the final exam scores of twenty introductory statistics students.

57, 66, 69, 71, 72, 73, 74, 77, 78, 78, 79, 79, 81, 81, 82, 83, 83, 88, 89, 94

Create a box plot of the distribution of these scores. The five number summary provided below may be useful.


Mix-and-match. (2.10, p. 57) Describe the distribution in the histograms below and match them to the box plots.

  1. The first histogram (a) is unimodal, with a centered mean of about 60. There is no right or left skew, so the distribution is “gaussian”. This histogram matches up with the second boxplot (2).

  2. The second histogram (b) doesn’t really have any peaks, and can be considered a uniform distribution. It matches with the third boxplot (3). There are no outliers and values are distributed evenly between 0-100.

  3. The third distribution (c) is unimodal with a right skew. It matches up with the first boxplot (1). 75% of data falls below the value 2, yet we see many outliers as high as 7.


Distributions and appropriate statistics, Part II. (2.16, p. 59) For each of the following, state whether you expect the distribution to be symmetric, right skewed, or left skewed. Also specify whether the mean or median would best represent a typical observation in the data, and whether the variability of observations would be best represented using the standard deviation or IQR. Explain your reasoning.

  1. Housing prices in a country where 25% of the houses cost below $350,000, 50% of the houses cost below $450,000, 75% of the houses cost below $1,000,000 and there are a meaningful number of houses that cost more than $6,000,000.
  2. Housing prices in a country where 25% of the houses cost below $300,000, 50% of the houses cost below $600,000, 75% of the houses cost below $900,000 and very few houses that cost more than $1,200,000.
  3. Number of alcoholic drinks consumed by college students in a given week. Assume that most of these students don’t drink since they are under 21 years old, and only a few drink excessively.
  4. Annual salaries of the employees at a Fortune 500 company where only a few high level executives earn much higher salaries than the all other employees.

Answers

  1. Based on the provided description of data, this distribution would be right skewed. Because of the many outliers, it makes sense to use the Median and IQR rather than the Mean and Standard Variation.

  2. Based on the provided description of data, this distribution would be symmetrical. Because there are not many outliers to consider, using the Mean and Standard Deviation is better suited than the Median and IQR.

  3. This distribution would be right skewed since most of the college students drinks-per-week would be centered around zero. There will be a handful of students drinking excessively, but these students are outliers. We should use the Median and IQR in this case because of the outliers present.

  4. The distribution in this case would be right skewed. This is because the majority of employees will have relatively similar salaries, compared against the few executives with much larger incomes. We can use the median and IQR to represent the data meaningfully.


Heart transplants. (2.26, p. 76) The Stanford University Heart Transplant Study was conducted to determine whether an experimental heart transplant program increased lifespan. Each patient entering the program was designated an official heart transplant candidate, meaning that he was gravely ill and would most likely benefit from a new heart. Some patients got a transplant and some did not. The variable transplant indicates which group the patients were in; patients in the treatment group got a transplant and those in the control group did not. Of the 34 patients in the control group, 30 died. Of the 69 people in the treatment group, 45 died. Another variable called survived was used to indicate whether or not the patient was alive at the end of the study.

  1. Based on the mosaic plot, is survival independent of whether or not the patient got a transplant? Explain your reasoning.

Answer: The vertical locations at which the treatment and control groups break into the alive and dead categories differ, which indicates an increased likelihood of survival with the occurance of a heart transplant. This suggests that the two variables may be dependent.

  1. What do the box plots below suggest about the efficacy (effectiveness) of the heart transplant treatment.

Answer: The boxplots suggest that heart transplants increase the survival time for individuals classified as at-risk heart transplant candidates.

  1. What proportion of patients in the treatment group and what proportion of patients in the control group died?
heart_transplant %>% group_by(transplant, survived) %>% summarise(count = n())
## `summarise()` has grouped output by 'transplant'. You can override using the `.groups` argument.

Answer: - 30/34 patients in the control group died (.8823) - 45/69 patients in the treatment group died (.6521)

  1. One approach for investigating whether or not the treatment is effective is to use a randomization technique.
  1. What are the claims being tested?

Answer: “Heart transplant surgery increases the survival time for at-risk heart transplant candidates”. And alternatively, “Heart transplant surgery does not impact the survival time of at-risk heart transplant candidates”

  1. The paragraph below describes the set up for such approach, if we were to do it without using statistical software. Fill in the blanks with a number or phrase, whichever is appropriate.

We write alive on ____28____ cards representing patients who were alive at the end of the study, and dead on ____75____ cards representing patients who were not. Then, we shuffle these cards and split them into two groups: one group of size ____69____ representing treatment, and another group of size ____34____ representing control. We calculate the difference between the proportion of dead cards in the treatment and control groups (treatment - control) and record this value. We repeat this 100 times to build a distribution centered at ____0_. Lastly, we calculate the fraction of simulations where the simulated differences in proportions are _at-least (30/34)-(45/69)=.2303____. If this fraction is low, we conclude that it is unlikely to have observed such an outcome by chance and that the null hypothesis should be rejected in favor of the alternative.

  1. What do the simulation results shown below suggest about the effectiveness of the transplant program?

Answer: Because only one observation from the simulations has a difference greater than 23%, we should reject the null hypothesis. Patient outcomes are influenced by treatment.

\begin{center} \end{center}