1.8 Smoking habits of UK residents.

1.10 Cheaters, scope of inference.

1.28 Reading the paper.

1.36 Exercise and mental health.

1.48 Stats scores.

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.

library(tidyverse)
scores <- c(57, 66, 69, 71, 72, 73, 74, 77, 78, 78, 79, 79, 81, 81, 82, 83, 83, 88, 89, 94)
scores <- as.data.frame(scores)
ggplot(scores,aes(y=scores))+
  geom_boxplot()

1.50 Mix-and-match.

Describe the distribution in the histograms below and match them to the box plots.

(a)This one can consider to be symmetric and matches the boxplot (2).

(b)The distribution is kind of distribute evently,and matches the boxplot (3). 

(c)The distribution is right skewed, unimodel and matches the boxplot (1).

1.56 Distributions and appropriate statistics, Part II.

(a) Right skewed(median<mean), Median and IQR

(b) Symmetric, Median and IQR

(c) Left skewed(mean<median), Median and IQR

(d) Right skewed(median<mean), Median and IQR

1.70 Heart transplants.

library(openintro)
data(heartTr)

treat_group <- heartTr %>% 
  group_by(transplant) %>% 
  count(survived) %>%
  filter(transplant == 'treatment') %>%
  mutate(percentage = n/sum(n))
treat_rate <- round(treat_group[2,4]*100,2)
treat_group
## # A tibble: 2 x 4
## # Groups:   transplant [1]
##   transplant survived     n percentage
##   <fct>      <fct>    <int>      <dbl>
## 1 treatment  alive       24      0.348
## 2 treatment  dead        45      0.652
print(paste0("The proportion of patients in the control group died is: ",treat_rate,"%"))
## [1] "The proportion of patients in the control group died is: 65.22%"
control_group <- heartTr %>% 
  group_by(transplant) %>% 
  count(survived) %>%
  filter(transplant == 'control') %>%
  mutate(percentage = n/sum(n))
control_rate <- round(control_group[2,4]*100,2)
control_group
## # A tibble: 2 x 4
## # Groups:   transplant [1]
##   transplant survived     n percentage
##   <fct>      <fct>    <int>      <dbl>
## 1 control    alive        4      0.118
## 2 control    dead        30      0.882
print(paste0("The proportion of patients in the control group died is: ",control_rate,"%"))
## [1] "The proportion of patients in the control group died is: 88.24%"
  1. What are the claims being tested?

    The claim being tested is that a heart transplant increased lifespan.
  2. Second

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 betwen 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 23.02%. 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?

    Two of the 100 simulations had a difference of at least 23.02%, the difference observed in the study. We conclude the evidence is suciently strong to reject H0 and assert that the transplant program is effective.