Titanic Case Study

This case study analyses the data available on The Titanic.

Titanic

Titanic

Number of Passengers

The total number of passengers on board the Titanic:

length(titanic.df$Survived)
## [1] 889

Number of Passengers who Survived

The number of passengers who survived the sinking of the Titanic.

table(titanic.df$Survived)
## 
##   0   1 
## 549 340

Titanic Sinking ## Percentage of Survived

The measure the percentage of passengers who survived the sinking of the Titanic:

 survived<-table(titanic.df$Survived)
prop.table(survived)*100
## 
##        0        1 
## 61.75478 38.24522

Number of First Class Survivors

The number of first-class passengers who survived the sinking of the Titanic:

first.survived<-xtabs(~ Survived + Pclass,titanic.df)
first.survived
##         Pclass
## Survived   1   2   3
##        0  80  97 372
##        1 134  87 119

Percentage of First Class Survivors

The percentage of first-class passengers who survived the sinking of the Titanic:

 prop.table(first.survived)*100
##         Pclass
## Survived         1         2         3
##        0  8.998875 10.911136 41.844769
##        1 15.073116  9.786277 13.385827

Number of Females who Survived

The number of females from First-Class who survived the sinking of the Titanic

 female.first.survived<-xtabs(~ Survived + Pclass+Sex,titanic.df)
 female.first.survived
## , , Sex = female
## 
##         Pclass
## Survived   1   2   3
##        0   3   6  72
##        1  89  70  72
## 
## , , Sex = male
## 
##         Pclass
## Survived   1   2   3
##        0  77  91 300
##        1  45  17  47

Survival ##Percentage of Survivors who were Female

The percentage of survivors who were female

female.survived<-xtabs(~ Survived +Sex,titanic.df)
prop.table(female.survived,1)*100
##         Sex
## Survived   female     male
##        0 14.75410 85.24590
##        1 67.94118 32.05882

Percentage of Female Survivors

The percentage of females on board the Titanic who survived:

female.titanic.survived<-xtabs(~ Survived + Sex,titanic.df)
prop.table(female.titanic.survived,1)*100
##         Sex
## Survived   female     male
##        0 14.75410 85.24590
##        1 67.94118 32.05882
Remember

Remember

Chi-squared Test

Pearson’s Chi-squared test to test the following hypothesis:

Hypothesis: The proportion of females onboard who survived the sinking of the Titanic was higher than the proportion of males onboard who survived the sinking of the Titanic.

survived<-xtabs(~ Sex+ Survived,titanic.df)
chisq.test(survived)
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  survived
## X-squared = 258.43, df = 1, p-value < 2.2e-16

Since the p value is very small(<0.05), the hypothesis that the proportion of females onboard who survived the sinking of the Titanic was higher than the proportion of males onboard who survived the sinking of the Titanic is True.