Richard Morris
2 May 2021
The Titanic Survival App predicts whether or not you would have survived the Titanic tragedy based on your age, sex and whether or not you think you would have travelled 1st, 2nd or 3rd class.
The app is deployed at: https://richard-morris.shinyapps.io/titanic/
'data.frame': 714 obs. of 4 variables:
$ Survived: int 0 1 1 1 0 0 0 1 1 1 ...
$ Class : Factor w/ 3 levels "1","2","3": 3 1 3 1 3 1 3 3 2 3 ...
$ Age : num 22 38 26 35 35 54 2 27 14 4 ...
$ Sex : Factor w/ 2 levels "female","male": 2 1 1 1 2 2 2 1 1 1 ...
glm(formula = Survived ~ Age + Sex + Class, family = binomial,
data = titanic)
Estimate Std. Error z value Pr(>|z|)
(Intercept) 3.77701265 0.401123305 9.416089 4.682044e-21
Age -0.03698527 0.007655948 -4.830919 1.359041e-06
Sexmale -2.52278092 0.207390924 -12.164375 4.811152e-34
Class2 -1.30979927 0.278065527 -4.710398 2.472337e-06
Class3 -2.58062532 0.281442020 -9.169296 4.761161e-20
Prob <- as.numeric(predict(model, type="response"))*100
titanic$Prob_Survival <- Prob
head(titanic)
Survived Class Age Sex Prob_Survival
1 0 3 22 male 10.526285
2 1 1 38 female 91.463372
3 1 3 26 female 55.842450
4 1 1 35 female 92.290788
5 0 3 35 male 6.780678
7 0 1 54 male 32.235446