library(readr) library(AER) 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) surv_mod <- lm(Survived ~ Class, data = Titanic_2) # compute the class specific estimates # fit the augmented LMP and assign it to `LPM_mod` # obtain a robust summary of the model coefficients # compute the class specific estimates surv_prob_c1 <- surv_mod$coefficients[1] surv_prob_c2 <- surv_prob_c1 + surv_mod$coefficients[2] surv_prob_c3 <- surv_prob_c1 + surv_mod$coefficients[3] # fit the linear probability model, assign it to `surv_mod` LPM_mod <- lm(Survived ~ ., data = Titanic_2) # obtain a robust summary of the model coefficients coeftest(LPM_mod, vcovHC) test_predefined_objects("Titanic_2") test_predefined_objects("surv_mod") test_object("surv_prob_c1") test_object("surv_prob_c2") test_object("surv_prob_c3") test_function("coeftest", args = c("x", "vcov.")) success_msg("Nice. The augmented LMP predicts that the probability of survival increases with the passenger class. The estimated coefficients on the passenger class dummies changed only marginally and remain highly significant. We conclude that there is no substantial OVB in the simple LPM of Exercise 5.")