1.8 Smoking habits of UK residents
(a) What does each row if the data matrix represent?
Each row represents a case or observation.
(b) How may participants were included in the survey?
The survey included 1691 participants.
(c) Indicate if each variable in the study is numerical or categorical
1. sex - categorical
2. age - numerical (discrete), though if placed in bins could be categorical (ordinal)
3. marital - categorical
4. gross income - categorical (ordinal)
5. smoke - categorical
6. amtWeekdays - Numerical (discrete) 7. amtWeekdays - Numerical (discrete)
1.10 Smoking habits of UK residents
(a) Identify the population of interest and the sample in the study?
The population is children between 5 and 15. The sample is comprised of 160 male and female children between 5 and 15
(b) Commment on if the results can be generalized to the population and if the findings of the study can be used to establish causal relationships.
The difference in the study could be random fluctation or they could be statistically meaningful. Not enough information is provided to make this assessment. Even if an association or associations were determined to exist, this does not mean there is a causal relationship, though one could exist.
1.28 Reading the paper
(a) Based on the study, can we conclude that smoking causes dementia later in life? Explain your answer
No, association does not mean a causal relationship exists. Additionally, it might be the case that the onset of dementia increases with age. Also, its possible the the sampling utilized could have introduced bias. Finally, causation can only be infered from a random experimental study - which this was not.
(b) A friend of yours who read the article says, the study shows that sleep disorders lead to bullying in school children. Is this statement justified? If not, how best can describe the conclusion that can be drawn from the study.
No, this was an observational study and therefore no causal association cna be determined. Additionally, itβs not clear if sleep disorder or bullying is the explanatory or response.
1.36 Exercise and Mental Health
(a)What type of study is this
experiment.
(b) What are the treatment and control groups in the study.
Treatment = exercise | Control = no exercise
(c) Does this study make use of blocking?.
Yes, the study is blocking with age.
(d) Does this study make use of blinding?.
If subjects knew it was a study that looked at the impact of exercise on mental health and some subjects were told not to exercise I would say no, blinding was not used. Though its not totally clear from reading the question.
(e) Comment on whether the results of the study can be used to estabish a causal relationship between exercise and mental health, and indicate whether or not the conclusions can be generalized to the population.
The study was an experiment and was random, so the study could establish a causal relationship and can be generalized to the population.
(f) Suppose you are given the task of determining if this study should get funding. Would you have any reservations about the study proposal?
No, the study appears to be designed well. It has a control group, its been randomized, there is replication and blocking.
1.48 Stat Scores
(a) Create a boxplot of the distribution of theses scores of twenty introductory statistics students.
stat_scores <- data.frame("scores" =c(57,66,69,71,72,73,74,77,78,78,79,79,81,81,82,83,83,88,89,94))
summary(stat_scores)
## scores
## Min. :57.00
## 1st Qu.:72.75
## Median :78.50
## Mean :77.70
## 3rd Qu.:82.25
## Max. :94.00
boxplot(stat_scores$scores, ylab='Student Scores', main='Distribution of Student Scores')
fivenum(stat_scores$scores)
## [1] 57.0 72.5 78.5 82.5 94.0
Question - Why does the summary command indicate that the 1st quartile is 72.75 and the fivenum indicates 72.5?
1.50 Mix and Match - Describe the distribution in the histograms below and match them to the box plots.
(a) Histogram a approximates a normal distribution and is fairly symetric and unimodal. It has a mean and median close to 60 and has some outliers. It matches to boxplot = 2
(b) Histogram, b appears to be multi-modal and without left or right tails. Histogram b matches to boxplot = 3
(c) Histogram c is right skewed (long right tail)and unimodal. It matches to boxplot = 1.
1.56 For each of the following state whether you expect the distribution to be symetric, right skewed, or left skewed. Also state if the mean or median would be the best representation of a typical observation in the data and whether the variability of the observations would be best represented by the standard deviation or IQR
(a) The distribution appears to be right skewed owing to the outlier homes with values over $6,000,000. This skew would make the median more representative than the mean. The large number of outliers, however, make the standard deviation more representative of the variability because IQR ignores outliers.
(b) This distribution appears to be more symetetric. Accordingly both median and mean should be close to one another and representive of typical observation. The lack of may outliers would make the IQR more representative of the variability.
(c) This distribution would be right skewed. Median and IQR since the number of outliers is small (only a few drink excessively)
(d) This is also right skewed. Median and standard deviation (sincer there would be more outliers)
1.70 Heart Transplants
library(openintro);data("heartTr")
## Please visit openintro.org for free statistics materials
##
## Attaching package: 'openintro'
## The following objects are masked from 'package:datasets':
##
## cars, trees
heartTr
## id acceptyear age survived survtime prior transplant wait
## 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
## 7 54 71 47 dead 3 no control NA
## 8 38 70 41 dead 5 no treatment 5
## 9 85 73 47 dead 5 no control NA
## 10 2 68 51 dead 6 no control NA
## 11 103 67 39 dead 6 no control NA
## 12 12 68 53 dead 8 no control NA
## 13 48 71 56 dead 9 no control NA
## 14 102 74 40 alive 11 no control NA
## 15 35 70 43 dead 12 no control NA
## 16 95 73 40 dead 16 no treatment 2
## 17 31 69 54 dead 16 no control NA
## 18 3 68 54 dead 16 no treatment 1
## 19 74 72 29 dead 17 no treatment 5
## 20 5 68 20 dead 18 no control NA
## 21 77 72 41 dead 21 no control NA
## 22 99 73 49 dead 21 no control NA
## 23 20 69 55 dead 28 no treatment 1
## 24 70 72 52 dead 30 no treatment 5
## 25 101 74 49 alive 31 no control NA
## 26 66 72 53 dead 32 no control NA
## 27 29 69 50 dead 35 no control NA
## 28 17 68 20 dead 36 no control NA
## 29 19 68 59 dead 37 no control NA
## 30 4 68 40 dead 39 no treatment 36
## 31 100 74 35 alive 39 yes treatment 38
## 32 8 68 45 dead 40 no control NA
## 33 44 70 42 dead 40 no control NA
## 34 16 68 56 dead 43 no treatment 20
## 35 45 71 36 dead 45 no treatment 1
## 36 1 67 30 dead 50 no control NA
## 37 22 69 42 dead 51 no treatment 12
## 38 39 70 50 dead 53 no treatment 2
## 39 10 68 42 dead 58 no treatment 12
## 40 35 71 52 dead 61 no treatment 10
## 41 37 70 61 dead 66 no treatment 19
## 42 68 72 45 dead 68 no treatment 3
## 43 60 71 49 dead 68 no treatment 3
## 44 62 71 39 dead 69 no control NA
## 45 28 69 53 dead 72 no treatment 71
## 46 47 71 47 dead 72 no treatment 21
## 47 32 69 64 dead 77 no treatment 17
## 48 65 72 51 dead 78 no treatment 12
## 49 83 73 53 dead 80 no treatment 32
## 50 13 68 54 dead 81 no treatment 17
## 51 9 68 47 dead 85 no control NA
## 52 73 72 56 dead 90 no treatment 27
## 53 79 72 53 dead 96 no treatment 67
## 54 36 70 48 dead 100 no treatment 46
## 55 32 71 41 dead 102 no control NA
## 56 98 73 28 alive 109 no treatment 96
## 57 87 73 46 dead 110 no treatment 60
## 58 97 73 23 alive 131 no treatment 21
## 59 37 71 41 dead 149 no control NA
## 60 11 68 47 dead 153 no treatment 26
## 61 94 73 43 dead 165 yes treatment 4
## 62 96 73 26 alive 180 no treatment 13
## 63 90 73 52 dead 186 yes treatment 160
## 64 53 71 47 dead 188 no treatment 41
## 65 89 73 51 dead 207 no treatment 139
## 66 24 69 51 dead 219 no treatment 83
## 67 27 69 8 dead 263 no control NA
## 68 93 73 47 alive 265 no treatment 28
## 69 51 71 48 dead 285 no treatment 32
## 70 67 73 19 dead 285 no treatment 57
## 71 16 68 49 dead 308 no treatment 28
## 72 84 73 42 dead 334 no treatment 37
## 73 91 73 47 dead 340 no control NA
## 74 92 73 44 alive 340 no treatment 310
## 75 58 71 47 dead 342 yes treatment 21
## 76 88 73 54 alive 370 no treatment 31
## 77 86 73 48 alive 397 no treatment 8
## 78 82 71 29 alive 427 no control NA
## 79 81 73 52 alive 445 no treatment 6
## 80 80 72 46 alive 482 yes treatment 26
## 81 78 72 48 alive 515 no treatment 210
## 82 76 72 52 alive 545 yes treatment 46
## 83 64 72 48 dead 583 yes treatment 32
## 84 72 72 26 alive 596 no treatment 4
## 85 71 72 47 alive 630 no treatment 31
## 86 69 72 47 alive 670 no treatment 10
## 87 7 68 50 dead 675 no treatment 51
## 88 23 69 58 dead 733 no treatment 3
## 89 63 71 32 alive 841 no treatment 27
## 90 30 69 44 dead 852 no treatment 16
## 91 59 71 41 alive 915 no treatment 78
## 92 56 71 38 alive 941 no treatment 67
## 93 50 71 45 dead 979 yes treatment 83
## 94 46 71 48 dead 995 yes treatment 2
## 95 21 69 43 dead 1032 no treatment 8
## 96 49 71 36 alive 1141 yes treatment 36
## 97 41 70 45 alive 1321 yes treatment 58
## 98 14 68 53 dead 1386 no treatment 37
## 99 26 69 30 alive 1400 no control NA
## 100 40 70 48 alive 1407 yes treatment 41
## 101 34 69 40 alive 1571 no treatment 23
## 102 33 69 48 alive 1586 no treatment 51
## 103 25 69 33 alive 1799 no treatment 25
str(heartTr)
## 'data.frame': 103 obs. of 8 variables:
## $ id : int 15 43 61 75 6 42 54 38 85 2 ...
## $ acceptyear: int 68 70 71 72 68 70 71 70 73 68 ...
## $ age : int 53 43 52 52 54 36 47 41 47 51 ...
## $ survived : Factor w/ 2 levels "alive","dead": 2 2 2 2 2 2 2 2 2 2 ...
## $ survtime : int 1 2 2 2 3 3 3 5 5 6 ...
## $ prior : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 1 1 1 1 ...
## $ transplant: Factor w/ 2 levels "control","treatment": 1 1 1 1 1 1 1 2 1 1 ...
## $ wait : int NA NA NA NA NA NA NA 5 NA NA ...
levels(heartTr$transplant)
## [1] "control" "treatment"
levels(heartTr$survived)
## [1] "alive" "dead"
(a) Based in the mosaic plot, is survival independent of whether or not the patient got a transplant?
No, based upon the mosaic plot survival does not appear to independent of whether the patient got a transplat. The mosaic plot show a higher survival rate for the Treatment group vs the Control group.
(b)What do the boxplots below suggest about the efficacy of the heart transplant treatment?
The box plot suggest that the transplant has a high efficacy rate. In the Control most of the patients died before 200 days. In the Treatment group the median survival days was higher than the Control and Treatment group member had a substantially better chance to survive more than 500 days
(c) What proportion of patients in the treatment group and what proportion of patients in the control group died?
treatment_dead_prop <- nrow(subset(heartTr, heartTr$transplant=="treatment" & heartTr$survived=="dead")) / nrow(subset(heartTr, heartTr$transplant=="treatment"))
treatment_dead_prop
## [1] 0.6521739
control_dead_prop <- nrow(subset(heartTr, heartTr$transplant=="control" & heartTr$survived=="dead")) / nrow(subset(heartTr, heartTr$transplant=="control"))
control_dead_prop
## [1] 0.8823529
(d) One approach for investigating whether or not the treatment is effective is to use a randomization technique.
i. What are the claims being tested?
Null Hypoth - current state transplants have no bearing on lifespan.
Alternative - heart transplats increase lifespan.
ii. 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.230179. 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?
Per item (ii) above, the fraction was low. Only 2% of the simulation results were in the range of -.230179. Therefore, we would conclude its not a random event and transplants do increase lifespan.