library(MASS) mod_pl <- lm(medv ~ poly(log(lstat), 2, raw = T), data = Boston) # set up the relevant data points # predict the corresponding values of medv # compute the expected effect of the change # set up the relevant data points new_data <- data.frame(lstat = c(10, 11)) # predict the corresponding values of medv Y_hat <- predict(mod_pl, newdata = new_data) # compute the expected effect of the change diff(Y_hat) ex() %>% check_object("new_data") %>% check_equal() ex() %>% check_object("Y_hat") %>% check_equal() ex() %>% check_function("diff") %>% check_result() %>% check_equal() success_msg("Correct! The expected change in medv for an increase in lstat from 10% to 11% is about -1.16 (that is -1160$).")