# install.packages("openintro")
library(openintro)
## Please visit openintro.org for free statistics materials
##
## Attaching package: 'openintro'
## The following objects are masked from 'package:datasets':
##
## cars, trees
data(heartTr)
data(smoking)
Answer:
nrow(smoking)
## [1] 1691
1691 participates were included in the survey. (c) Indicate whether each variable in the study is numerical or categorical. If numerical, identify as continuous or discrete. If categorical, indicate if the variable is ordinal. Answer:
sapply(smoking, class)
## gender age maritalStatus
## "factor" "integer" "factor"
## highestQualification nationality ethnicity
## "factor" "factor" "factor"
## grossIncome region smoke
## "factor" "factor" "factor"
## amtWeekends amtWeekdays type
## "integer" "integer" "factor"
sapply(smoking, table)
## $gender
##
## Female Male
## 965 726
##
## $age
##
## 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
## 15 13 22 11 12 14 15 17 26 18 19 22 30 26 29 38 24 36 40 31 32 33 31 34 43
## 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
## 31 37 20 33 34 22 23 20 31 21 24 20 21 34 31 17 34 23 28 15 27 18 21 28 24
## 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
## 25 23 23 30 18 18 31 31 13 21 25 20 28 25 16 18 13 4 5 5 8 3 4 7 3
## 91 93 95 97
## 2 2 1 1
##
## $maritalStatus
##
## Divorced Married Separated Single Widowed
## 161 812 68 427 223
##
## $highestQualification
##
## A Levels Degree GCSE/CSE GCSE/O Level
## 105 262 102 308
## Higher/Sub Degree No Qualification ONC/BTEC Other/Sub Degree
## 125 586 76 127
##
## $nationality
##
## British English Irish Other Refused Scottish Unknown Welsh
## 538 833 23 71 17 142 1 66
##
## $ethnicity
##
## Asian Black Chinese Mixed Refused Unknown White
## 41 34 27 14 13 2 1560
##
## $grossIncome
##
## 10,400 to 15,600 15,600 to 20,800 2,600 to 5,200 20,800 to 28,600
## 268 188 257 155
## 28,600 to 36,400 5,200 to 10,400 Above 36,400 Refused
## 79 396 89 108
## Under 2,600 Unknown
## 133 18
##
## $region
##
## London Midlands & East Anglia Scotland
## 182 443 148
## South East South West The North
## 252 157 426
## Wales
## 83
##
## $smoke
##
## No Yes
## 1270 421
##
## $amtWeekends
##
## 0 1 2 3 4 5 6 7 8 9 10 12 15 16 18 20 24 25
## 6 6 7 6 4 32 10 8 7 1 69 13 58 2 4 111 1 24
## 30 35 40 45 50 60
## 27 5 15 1 2 2
##
## $amtWeekdays
##
## 0 1 2 3 4 5 6 7 8 9 10 12 15 16 18 20 24 25 30 35 40 45 50 55
## 16 8 13 9 10 28 14 14 16 1 80 17 56 1 5 82 1 16 17 3 10 1 2 1
##
## $type
##
## Both/Mainly Hand-Rolled Both/Mainly Packets
## 1270 10 42
## Hand-Rolled Packets
## 72 297
Sex - Categorical age - numerical marital - categorical grossincome - categorical(ordinal) smoke - categorical amtWeekends - categorical(ordinal) amtWeekdays - caegeroical(ordinal) # 1.10 Cheaters, scope of inference
A researcher is interested in the effects of exercise on mental health and he proposes the following study: Use stratified random sampling to ensure rep- representative proportions of 18-30, 31-40 and 41- 55 year old from the population. Next, randomly assign half the subjects from each age group to exercise twice a week, and instruct the rest not to exercise. Conduct a mental health exam at the beginning and at the end of the study, and compare the results. (a) What type of study is this? Answer: This is an experimental study . (b) What are the treatment and control groups in this study? Answer: The control of this study is people who don’t exercise and the treatment group is the people who study. (c) Does this study make use of blocking? If so, what is the blocking variable? Answer: Yes. The study use blocking. The blocking variables are age group. (d) Does this study make use of blinding? Answer: The study don’t use blinding. (e) Comment on whether or not the results of the study can be used to establish a causal real- relationship between exercise and mental health, and indicate whether or not the conclusions can be generalized to the population at large. Answer: Te results of the study can be used to establish a causal relationship between exerciser and mental health, and indicates conclusion can not be generalized to the population at large as the study is experimental and it doesn’t include people of all ages. (f) Suppose you are given the task of determining if this proposed study should get funding. Would you have any reservations about the study proposal? Answer: The study doesn’t consider other factors as blocking factor like gender, weight etc. So I will have reservations to consider other factors.
stats <- c(57, 66, 69, 71, 72, 73, 74, 77, 78, 78, 79, 79, 81, 81, 82, 83, 83, 88, 89, 94)
boxplot(stats, main = "Score of Stats Scores")
# 1.50 Mix-and-match Answer: (a) histogram is approximately normally distributed, platykertic. (b) histogram if approximately uniformly distributed. (c) This histogram is negatively skewed. (a) box plot is negatively skewed, with large number of outlines. (2) Approximately normal distributions with outlines on the both ends. Mean, median and mode are approximately similar with smaller standard deviation. (3) Approximately normal distributed data with no outlines.
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) 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. Answer: The distribution is left skewed. The mean will best represent the data. The variability will be best represented using IQR as there are extreme values.
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. Another variable called survived was used to indicate whether or not the patient was alive at the end of the study. Of the 34 patients in the control group, 30 died. Of the 69 people in the treatment group, 45 died
Answer: Based on the mosaic plot the survival is not dependent of whether or not the patient got a transplant. In treat treatment group more patient survived than the control group.
data("heartTr")
dt <- prop.table(table(heartTr$transplant, heartTr$survived))*100
round(dt, 2)
##
## alive dead
## control 3.88 29.13
## treatment 23.30 43.69
In the treatment group 43.69 percent died and in the control group 29.13 percent died. (d) One approach for investigating whether or not the treatment is effective is to use a random- ionization technique. i. What are the claims being tested? Answer: The patients in the treatment group survived more than control group. ii. The paragraph below describes the set up for such approach, if we were to do it with- out using statistical software. Fill in the blanks with a number or phrase, whichever is appropriate. We write alive on \(\underline{Heart,Spades}\)cards representing patients who were alive at the end of the study, and dead on \(\underline{Diamond,Stars}\) cards representing patients who were not. Then, we shuffle these cards and split them into two groups: one group of size\(\underline{30}\) representing treatment, and another group of size \(\underline{30}\)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 \(\underline{mean}\). Lastly, we calculate the fraction of simulations where the simulated differences in proportions are \(\underline{small}\). 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.