this is the titanic case study

setwd("G:/IIEST 2K15-2K20/Intern/Internship/Resources/Week 1/week 1 day 5")
titanic.df <- read.csv(paste("Titanic Data1.csv", sep=""))

No of passengers survived in ship

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

mean of ages of all passengers

aggregate(titanic.df$Age, by=list(titanic.df$Survived), FUN=mean)
##   Group.1        x
## 1       0 30.41530
## 2       1 28.42382

Hypothesis 2 H2: H2: The Titanic survivors were younger than the passengers who died.

Independent t-test

A two-group independent t-test can be used to test the hypothesis that the two population means are equal. Here, we assume that the two groups are independent and that the data is sampled from normal populations. #t-test

t.test( Age ~ Survived, data=titanic.df)
## 
##  Welch Two Sample t-test
## 
## data:  Age by Survived
## t = 2.1816, df = 667.56, p-value = 0.02949
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.1990628 3.7838912
## sample estimates:
## mean in group 0 mean in group 1 
##        30.41530        28.42382

Result of Independent t-test The p-value = 0.00234(>0.001) Based on the above output of the t-test, we can’t reject the hypothesis that, The the Titanic survivors were younger than the passengers who died. as (p>0.001).(Ans)