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 Probit model and assign it to `Pogit_mod` # obtain a robust summary of the model coefficients # predict the probability of survival for the three passengers # fit the Probit model, assign it to `Probit_mod` Probit_mod <- glm(Survived ~ ., family = binomial(link = "probit"), data = Titanic_2) # obtain a robust summary of the model coefficients coeftest(Probit_mod, vcovHC) # predict the probability of survival for the hypothecial individuals predict(Probit_mod, newdata = passengers, type = "response") test_predefined_objects("Titanic_2") test_object("Probit_mod") test_predefined_objects("passengers") test_output_contains("predict(Probit_mod, newdata = passengers, type = 'response')") success_msg("Nicely done! Note that ")