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. Min Q1 Q2(Median) Q3 Max 57 72.5 78.5 82.5 94
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.1
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.4 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.1 v forcats 0.5.1
## Warning: package 'tibble' was built under R version 4.1.1
## Warning: package 'readr' was built under R version 4.1.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
scores <- c(57, 66, 69, 71, 72, 73, 74, 77, 78, 78, 79, 79, 81, 81, 82, 83, 83, 88, 89, 94)
Exam_scores <- data.frame(scores)
summary(Exam_scores)
## scores
## Min. :57.00
## 1st Qu.:72.75
## Median :78.50
## Mean :77.70
## 3rd Qu.:82.25
## Max. :94.00
ggplot(Exam_scores, aes(y=scores)) + geom_boxplot() + labs(title="Distribution of Final Exam Scores") + ylab("Scores") + theme(legend.position = "none", axis.title.x = element_blank(), axis.text.x = element_blank(), axis.ticks.x = element_blank()) + theme(plot.title = element_text(hjust=0.5))
Mix-and-match. (2.10, p. 57) Describe the distribution in the histograms below and match them to the box plots.
*The histogram (a) matches the box plot (2). The distribution of histrogram (a) is symmetric and normally distributed.
*The histogram (b) matches the box plot (3). The distribuion of histogram (b) is multimodal distribution because multiple peaks, which values occur more frequently than any other, in the distribution.
*The histogram (c) matches the box plot (1). The distribution of histogram (c) is right skewed because the tail on the right side of the histrogram is longer than the left side.
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.
(a) The distribution is right skewed because the there are more data in the right of the distribution. The median would be best to represent a typical observation in the data because the data is skewed. The variability of observations would be best represented by Inter Quartile Range (IQR) because the distribution is skewed.
(b) The distribution is symmetric because the difference between the prices of first and second quartile is same as the differencce between the prices of second and third quartile. Both mean and median could be used to represent a typical observation in the data because the data is symmetric. *The variability of observations could be best represented by either Standard Deviation or Inter Quartile Range (IQR) because the distribution is symmetric.
(c) The distribution is right skewed because most of the student don’t drink and only a few students drink excessively. The median would be best to represent a typical observation in the data because there are outliners present in the data. The variability of observations would be best represented by Inter Quartile Range (IQR) because the distribution is skewed.
(d) The distribution is left skewed because only a few high level executives earn much higher salaries. The median would be best to represent a typical observation in the data because the data is skewed. The variability of observations would be best represented by Inter Quartile Range (IQR) because the distribution is skewed.
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 he end of the study
Load the openintro package
library(openintro)
## Warning: package 'openintro' was built under R version 4.1.1
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
This reads the file from Openintro into a tibble (dataframe) and take a glimpse of the data
data(heart_transplant, package='openintro')
head(heart_transplant)
## # A tibble: 6 x 8
## id acceptyear age survived survtime prior transplant wait
## <int> <int> <int> <fct> <int> <fct> <fct> <int>
## 1 15 68 53 dead 1 no control NA
## 2 43 70 43 dead 2 no control NA
## 3 61 71 52 dead 2 no control NA
## 4 75 72 52 dead 2 no control NA
## 5 6 68 54 dead 3 no control NA
## 6 42 70 36 dead 3 no control NA
Based on the mosaic plot, is survival independent of whether or not the patient got a transplant? Explain your reasoning.
Based on the mosaic plot, there is significant evidence that survival may be dependant on whether a patient got heart transplant or not. This is so because the survival rates are not the same for both groups (the survival rates in the treatment group is larger than control group).
What do the box plots below suggest about the efficacy (effectiveness) of the heart transplant treatment.
The box plots suggest that treatment is effective as the distribution of survival time for the treatment group is larger than the control group. The median survival time is higher and interquartile range is larger for the treatment group.
What proportion of patients in the treatment group and what proportion of patients in the control group died?
treatment_died <- (45 / 69);
formatC(treatment_died)
## [1] "0.6522"
control_died <- (30 / 34);
formatC(control_died)
## [1] "0.8824"
(d) One approach for investigating whether or not the treatment is effective is to use a randomization technique. What are the claims being tested?
(i) That there is no difference in proportion of dead patients between treatment and control group. It also known as Null Hypothesis H0(p1−p2)=0.
That there is significant difference in proportion of dead patients between treatment and control group. it’s also known as Alternative Hypothesis HA(p1−p2)≠0.
(ii)
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.25______. Lastly, we calculate the fraction of simulations where the simulated differences in proportions are ___ 0.2______. 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.
(iii) What do the simulation results shown below suggest about the effectiveness of the transplant program?
Answer
The simulation results suggest that the difference in proportion of dead patients between treatment and control group is not due to chance.