Sinking of the RMS Titanic

Time 23:40 - 02:20 Date 14-15 April 1912 Location North Atlantic Ocean Cause Collision with iceberg on 14 April 1912

Outcome Between 1,490 and 1,635 deaths Improvements to navigational safety Cultural impact

titanic.df <- read.csv(paste("Titanic Data.csv", sep=""))

A sample view of Titanic Dataset.

head(titanic.df)
##   Survived Pclass    Sex  Age SibSp Parch    Fare Embarked
## 1        0      3   male 22.0     1     0  7.2500        S
## 2        1      1 female 38.0     1     0 71.2833        C
## 3        1      3 female 26.0     0     0  7.9250        S
## 4        1      1 female 35.0     1     0 53.1000        S
## 5        0      3   male 35.0     0     0  8.0500        S
## 6        0      3   male 29.7     0     0  8.4583        Q

The total number of passengers on board the Titanic.

Here “n” = Total number of passengers on board the Titanic.

library(psych)
describe(titanic.df$Survived)
##    vars   n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 889 0.38 0.49      0    0.35   0   0   1     1 0.48    -1.77 0.02

According to the table total Number of passengers on board is : 889 ## The number of passengers who survived the sinking of the Titanic.

Here “0” denotes the passengers who haven’t servived . “1” denotes the passengers who have servived .

data.frame(table(titanic.df$Survived))
##   Var1 Freq
## 1    0  549
## 2    1  340

According to the table : The number of passengers who servived is 340

The percentage of passengers who survived the sinking of the Titanic

Here “0” denotes the passengers who haven’t servived in percentage. “1” denotes the passengers who have servived in percentage.

mytab <- with(titanic.df , table(Survived))


prop.table(mytab)*100
## Survived
##        0        1 
## 61.75478 38.24522

According to this table: 38.24522% were survived.

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

Here in the table pclass denoted the class of the passengers and 0 denotes who haven’t servived and 1 denotes who have servived

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

According to this table: Only 134 1st class passengers were survived

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

Here in the table pclass denoted the class of the passengers and 0 denotes who haven’t servived and 1 denotes who have servived

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

According to this table : out of the total passengers15.073116% 1st class passengers were survived

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

Here in the table pclass denoted the class of the passengers and 0 denotes who haven’t servived and 1 denotes who have servived and Sex denotes the gender .Male and female both are mentioned in the table

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

According to the table :The number of females from First-Class who survived the sinking of the Titanic is89

Measure the percentage of survivors who were female

Here in the table 0 denotes who haven’t servived and 1 denotes who have servived and Sex denotes the gender . Male and female both are mentioned in the table

mytable2 <- xtabs(~Survived+Sex , data = titanic.df)


prop.table(mytable2,1)*100
##         Sex
## Survived   female     male
##        0 14.75410 85.24590
##        1 67.94118 32.05882

According to this table : out of the total Survived passengers 67.94118% female Passengers were survived.

Measure the percentage of females on board the Titanic who survived

Here in the table 0 denotes who haven’t servived and 1 denotes who have servived and Sex denotes the gender . Male and female both are mentioned in the table

prop.table(mytable2)*100
##         Sex
## Survived    female      male
##        0  9.111361 52.643420
##        1 25.984252 12.260967

According to this table : out of the total female passengers 25.984252% female Passengers were survived.

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.

mytable3 <- prop.table(mytable2)
mytable3
##         Sex
## Survived     female       male
##        0 0.09111361 0.52643420
##        1 0.25984252 0.12260967
chisq.test(mytable3)
## Warning in chisq.test(mytable3): Chi-squared approximation may be incorrect
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  mytable3
## X-squared = 5.7395e-33, df = 1, p-value = 1

This time, there does not appear to be a relationship between the females who were servived and males who were survived, since we see that p > 0.05.

Since this probability is not small (p > 0.05), we fail to reject the null hypothesis that females onboard who survived the sinking of the Titanic was higher than the proportion of males onboard who survived the sinking of the Titanic