myData <- read.csv(paste("Titanic Data.csv"))
head(myData)
## 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
aveSur <- aggregate(myData$Age, by=list(myData$Survived), FUN=mean)
aveSur
## Group.1 x
## 1 0 30.41530
## 2 1 28.42382
The average age of survivers is : 28.42382 The average age of non survivers is: 30.41530
It is observed that average age of survivers is less than tha average age of dead people. This hypothesis will be verified in the next section
H0: There is no significant difference between the average age of people of survived and people who dies. H1: The average age of people of died is less than the average age of people who survived
t.test(myData$Age~myData$Survived)
##
## Welch Two Sample t-test
##
## data: myData$Age by myData$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
```
value of p = 00.0294 P>0.01 Therefore, we accept the null hypothesis that, There is no significant difference between average age of people who died and average age of people who survived.