Sinking of the RMS Titanic

(4a)Reading

setwd("C:/Users/Shreyas Jadhav/Downloads")  
titanic <- read.csv(paste("Titanic Data.csv",sep="."))
View(titanic)

Extended Analysis

(4b) A table showing the average age of the survivors and the average age of the people who died.

titanic$Survived = factor(titanic$Survived, levels = c(0,1), labels = c("Not Survived","Survived"))
aggregate(Age ~ Survived, data= titanic,mean)
##       Survived      Age
## 1 Not Survived 30.41530
## 2     Survived 28.42382

(4c)Run a t-test to test the following hypothesis: H2: The Titanic survivors were younger than the passengers who died.

log.transformed.Age=log(titanic$Age)
 t.test(log.transformed.Age ~ titanic$Survived,var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  log.transformed.Age by titanic$Survived
## t = 3.844, df = 887, p-value = 0.0001297
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.09102778 0.28094770
## sample estimates:
## mean in group Not Survived     mean in group Survived 
##                   3.304318                   3.118330

Result Interpretation

  1. From (4b), the average age of the survivors(28.42382) ia less than the average age of the people who died(30.41530).

Null Hypothesis: “There is no significant difference in the average age of the survivors and the average age of the people who died.”

  1. From (4c), p-value = 0.0001297 i.e p-value < 0.05 which mean we reject the Null Hypothesis and accept the alternative Hypothesis.

Alternative Hypothesis: “There is a significant difference in the average age of the survivors and the average age of the people who died.”

  1. Therefore, the t-test shows that There is a significant difference in the average age of the survivors and the average age of the people who died. The Titanic survivors were younger than the passengers who died.