1.8 Smoking Habits of UK Residents
library(openintro)
## Please visit openintro.org for free statistics materials
##
## Attaching package: 'openintro'
## The following objects are masked from 'package:datasets':
##
## cars, trees
smokingdf <- read.csv("smoking.csv")
Q: What does each row of the data matrix represent?
names(smokingdf)
## [1] "gender" "age" "maritalStatus"
## [4] "highestQualification" "nationality" "ethnicity"
## [7] "grossIncome" "region" "smoke"
## [10] "amtWeekends" "amtWeekdays" "type"
Each row contain information anout UK resident that include gender, age, marital status, highest qualification, nationality, ethnicity, gross income, region, smoking habits, type of cigarettes used and number of cigarettes smoked during weekday and weekend.
Q. How many participants were included in the survey?
dim(smokingdf)
## [1] 1691 12
There are 1691 participants in the survey.
Q. 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.
str(smokingdf)
## 'data.frame': 1691 obs. of 12 variables:
## $ gender : Factor w/ 2 levels "Female","Male": 2 1 2 1 1 1 2 2 2 1 ...
## $ age : int 38 42 40 40 39 37 53 44 40 41 ...
## $ maritalStatus : Factor w/ 5 levels "Divorced","Married",..: 1 4 2 2 2 2 2 4 4 2 ...
## $ highestQualification: Factor w/ 8 levels "A Levels","Degree",..: 6 6 2 2 4 4 2 2 3 6 ...
## $ nationality : Factor w/ 8 levels "British","English",..: 1 1 2 2 1 1 1 2 2 2 ...
## $ ethnicity : Factor w/ 7 levels "Asian","Black",..: 7 7 7 7 7 7 7 7 7 7 ...
## $ grossIncome : Factor w/ 10 levels "10,400 to 15,600",..: 3 9 5 1 3 2 7 1 3 6 ...
## $ region : Factor w/ 7 levels "London","Midlands & East Anglia",..: 6 6 6 6 6 6 6 6 6 6 ...
## $ smoke : Factor w/ 2 levels "No","Yes": 1 2 1 1 1 1 2 1 2 2 ...
## $ amtWeekends : int NA 12 NA NA NA NA 6 NA 8 15 ...
## $ amtWeekdays : int NA 12 NA NA NA NA 6 NA 8 12 ...
## $ type : Factor w/ 5 levels "","Both/Mainly Hand-Rolled",..: 1 5 1 1 1 1 5 1 4 5 ...
- Variable gender is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable.
- Variable age is numerical. Variable can be part of arithmetic operations including addition, subtraction and average. It can have wide range of positive values. Hence it is continuous variable.
- Variable maritalStatus is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable. It is nominal variable.
- Variable highestQualification is categorical. This is a ordinal variable because it can ordered from (No Qualification, Higher/Sub Degree, Degree).
- Variable nationality is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable. It is nominal variable.
- Variable ethnicity is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable. It is nominal variable.
- Variable grossIncome is numerical. Variable can be part of arithmetic operations including addition, subtraction and average. It can have wide range of values. Hence it is continuous variable.
- Variable region is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable. It is nominal variable.
- Variable smoke is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable. It is nominal variable.
- Variable amtWeekends is numerical. Variable can be part of arithmetic operations including addition, subtraction and average. It represents count of cigarettes smoked during weekends. Hence it is discrete variable.
- Variable amtWeekdays is numerical. Variable can be part of arithmetic operations including addition, subtraction and average. It represents count of cigarettes smoked during weekdays. Hence it is discrete variable.
- Variable type is categorical. This is not ordinal variable because there is no intrinsic ordering for the variable. It is nominal variable.
1.10 Cheaters, scope of inference.
Q: Identify the population of interest and the sample in this study.
Population of interest is all the childern between ages 5 and 15 that include boys and girls. Sample size of 160 childern are seleccted. They were asked to toss a fair coin in private and report the outcome black or white. They were also informed child who reports white would be rewarded. Each child was ramdomly assigned to one of the two groups Instruction group: This group was given explict instructions not to cheat. No Instruction group: This group was not given any explict instructions not to cheat.
Q: Comment on whether or not the results of the study can be generalized to the population, and if the findings of the study can be used to establish causal relationships.
After reading study conducted by Alessandro Bucciol and Marco Piovesan, “Luck or cheating? A field experiment on honesty with children”.
If opportunity permits, children cheat when cheating is profitable and they are not observed. Since observation establishes cheating develops from young age and can be avoided by reminding, it is fair say if general population is reminded cheating can be avoided to great extent irrespective of age.
1.28 Reading the paper
An article titled Risks: Smokers Found More Prone to Dementia states the following: “Researchers analyzed data from 23,123 health plan members who participated in a voluntary exam and health behavior survey from 1978 to 1985, when they were 50-60 years old. 23 years later, about 25% of the group had dementia, including 1,136 with Alzheimer’s disease and 416 with vascular dementia. After adjusting for other factors, the researchers concluded that pack-a- day smokers were 37% more likely than nonsmokers to develop dementia, and the risks went up with increased smoking; 44% for one to two packs a day; and twice the risk for more than two packs.”
Q: Based on this study, can we conclude that smoking causes dementia later in life? Explain your reasoning.
Based on the study it was observed that smoker has high chance of developing dementia later in life regardless of age and family history. We cannot conclude smoking causes dementia because of other variables including age and family history.
“The University of Michigan study, collected survey data from parents on each child’s sleep habits and asked both parents and teachers to assess behavioral concerns. About a third of the students studied were identified by parents or teachers as having problems with disruptive behavior or bullying. The researchers found that children who had behavioral issues and those who were identified as bullies were twice as likely to have shown symptoms of sleep disorders.”
Q: 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 you describe the conclusion that can be drawn from this study?
The Study simply shows an association between sleep problems and bad behavior and doesn’t prove that sleep problems cause bullying.
I think that impaired sleep does affect areas of the brain. If sleep is disrupted, then decision-making capabilities are impaired which will lead to behavioral issues. I do not agree with the friend that bullying is an effect of sleep disorder.
1.36 Exercise and mental health.
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- resentative proportions of 18-30, 31-40 and 41- 55 year olds 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.
Q: What type of study is this?
This is observational prospective study using stratified sampling. This study will be focusing on effect of exercise on mental health.
Q: What are the treatment and control groups in this study?
Treatment group: Subjects instructed to exercise twice a week. Control group: Subjects instructed not to exercise.
Q: Does this study make use of blocking? If so, what is the blocking variable?
Yes study does use blocking. Blocking variable is age of the subject.
Q: Does this study make use of blinding?
Study does not use blinding. Subjects are given instructions.
Q: Comment on whether or not the results of the study can be used to establish a causal relationship between exercise and mental health, and indicate whether or not the conclusions can be generalized to the population at large.
This is an observational study with many confounding variables not being measured. One such variable is diety habits. Hence study cannot easily be used to make causal conclusions. Also conclusions cannot be generalized to the population at large because study uses blocking. Subjects in the study were between the age group of 18 and 55.
Q: Suppose you are given the task of determining if this proposed study should get funding. Would you have any reservations about the study proposal?
Yes. If I was tasked to determine should the study get funding I would have liked to see study include diet as one of the variables and probably a broader age group.
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
r scores<-c(57, 66, 69, 71, 72, 73, 74, 77, 78, 78, 79, 79, 81, 81, 82, 83, 83, 88, 89, 94) summary(scores)
## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 57.00 72.75 78.50 77.70 82.25 94.00
r boxplot(scores)
1.50 Mix-and-match. Describe the distribution in the histograms below and match them to the box plots.
Histogram (a) has median 60 and distribution is right skewed. It matches to boxplot (2). Histogram (b) has median 50 and distribution is symmetric. It matches to boxplot (3). Histogram (c) has median less than 2 and distribution is right skewed. It matches to boxplot (1).
1.56 Distributions and appropriate statistics, Part II
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.
Right skewed.
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.
Distribution is symmetric.
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.
Right skewed.
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.
Right skewed.
1.70 Heart transplants.
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.
Q: Based on the mosaic plot, is survival independent of whether or not the patient got a transplant? Explain your reasoning.
library (RCurl)
## Warning: package 'RCurl' was built under R version 3.4.4
## Loading required package: bitops
url<-getURL("https://raw.githubusercontent.com/jbryer/DATA606Fall2018/master/data/openintro.org/Ch%201%20Exercise%20Data/heartTr.csv")
hearttr_df<-data.frame(read.csv(text=url,header=TRUE))
head(hearttr_df)
## 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
summary (hearttr_df)
## id acceptyear age survived
## Min. : 1.0 Min. :67.00 Min. : 8.00 alive:28
## 1st Qu.: 26.5 1st Qu.:69.00 1st Qu.:41.00 dead :75
## Median : 49.0 Median :71.00 Median :47.00
## Mean : 51.4 Mean :70.62 Mean :44.64
## 3rd Qu.: 77.5 3rd Qu.:72.00 3rd Qu.:52.00
## Max. :103.0 Max. :74.00 Max. :64.00
##
## survtime prior transplant wait
## Min. : 1.0 no :91 control :34 Min. : 1.00
## 1st Qu.: 33.5 yes:12 treatment:69 1st Qu.: 10.00
## Median : 90.0 Median : 26.00
## Mean : 310.2 Mean : 38.42
## 3rd Qu.: 412.0 3rd Qu.: 46.00
## Max. :1799.0 Max. :310.00
## NA's :34
boxplot(hearttr_df$survtime ~ hearttr_df$transplant)
Based on mosaic plot percentage of patients who received heart transplant survived longer. So, survival and heart transplant aren’t independent.
Q: What do the box plots below suggest about the efficacy (ectiveness) of the heart transplant treatment.
Box plot suggests patients survival has increased due to heart transplant treatment. Survival is evenly distributed with few outliers who survived more than 1500 days after treatment. Distribution is right skewed.
Q: What proportion of patients in the treatment group and what proportion of patients in the control group died?
88% of patients died in control group. 66% of patients died in treatment group.
Q 4: What are the claims being tested?
Claim1:- Heart transplant treatment has no effect on patient survival rate. (Null Hypothesis)
Claim2:- Heart transplant treatment increases patient survial rate and are not independent.
Fil in the blanks
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 patients representing treatment, and another group of size 34 patients 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 zero. Lastly, we calculate the fraction of simulations where the simulated differences in proportions are higher than observed differences in proportions. 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.
Q: What do the simulation results shown below suggest about the effectiveness of the transplant program?
According to the sumulation results it appears that difference in survival rate of treated and non treated patients is not just by chance and the treatment definitely increases the chance of survival amongst patients. The null hypothesis should be rejected