library(readr) library(AER) library(dplyr) Titanic_2 <- read_csv("https://stanford.io/2O9RUCF")[,-3] colnames(Titanic_2) = c("Survived", "Class", "Sex", "Age", "Siblings", "Parents", "Fare") Titanic_2$Class <- as.factor(Titanic_2$Class) passengers <- cbind("Class" = as.factor(1:3), as.data.frame(Titanic_2 %>% select(-Sex,-Survived,-Class) %>% summarise_all(funs(mean)) %>% mutate(Sex = "male"))) # fit the Logit model and assign it to `Logit_mod` # obtain a robust summary of the model coefficients # predict the probability of survival for the three passengers # fit the Logit model, assign it to `Logit_mod` Logit_mod <- glm(Survived ~ ., family = binomial(link = "logit"), data = Titanic_2) # obtain a robust summary of the model coefficients coeftest(Logit_mod, vcovHC) # predict the probability of survival for the hypothecial individuals predict(Logit_mod, newdata = passengers, type = "response") test_predefined_objects("Titanic_2") test_object("Logit_mod") test_predefined_objects("passengers") test_output_contains("predict(Logit_mod, newdata = passengers, type = 'response') ") success_msg("Nicely done! Note that ")