Analysis for Titanic Data
aggregate(tit.df$Age, by= list(tit.df$Survived), FUN= mean)
## Group.1 x
## 1 0 30.41530
## 2 1 28.42382
The average age of survivors is 28.42 years
The average age of people who died is 30.41 years.
a t-test to test the following hypothesis: H2: The Titanic survivors were younger than the passengers who died.
attach(tit.df)
t.test(Survived ,Age, paired =TRUE)
##
## Paired t-test
##
## data: Survived and Age
## t = -67.065, df = 888, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -30.12782 -28.41458
## sample estimates:
## mean of the differences
## -29.2712
The p value is 2.2e-16
Based on the above output of the test, we can reject the hypothesis that The tittanic survivors and people who died had same age.(p<.01)