Would You Survive the Sinking of the Titanic?

Keith Erskine
10Feb2019

#The Ship

What Determines the Chance of Survival?

The Three Factors that determine your survival of the Titanic Sinking are:

  • Your Age: The younger you are, the better
  • Your Gender: Women survived better than Men
  • Your Passenger Class: Like boarding an aircraft, the higher class fare is an advantage

app

How is the Prediction Made?

For this project, a simple binomaial regression model was created using the three variables: Age, Sex, and Pclass.

Data is the passenger manifest of the Titanic and whether the passenger lived or died.

t <- read.csv("titanic.csv")
head(t)[,c(1, 2, 4, 5)]
  Survived Pclass    Sex Age
1        0      3   male  22
2        1      1 female  38
3        1      3 female  26
4        1      1 female  35
5        0      3   male  35
6        0      3   male  27
fit <- glm(Survived ~ Age + Pclass + Sex, data = t, family = binomial())
summary(fit)$coefficients
               Estimate  Std. Error    z value     Pr(>|z|)
(Intercept)  4.87851130 0.463473967  10.525966 6.558510e-26
Age         -0.03436144 0.007134324  -4.816356 1.462035e-06
Pclass      -1.23053773 0.124957235  -9.847671 7.015074e-23
Sexmale     -2.58916304 0.186932921 -13.850760 1.258731e-43

The model shows that if you're male, older, and have a lower class ticket, you stand a lower chance of survival.

How is the Prediction Made?

The application makes a prediction based on the inputs from the ui.R. Here's a prediction using the default values:

unname(
        predict(fit, 
                newdata = data.frame(Age = 28, 
                                     Pclass = 1, 
                                     Sex = "male"), 
                type = "response")
        )
[1] 0.5241537

It checks out!

Thank You!

Thanks to Kaggle, encyclopedia-titanica, and Stanford Univ. for the dataset Jack and Rose