Business Finance Homework Help
Western Michigan University Healthcare Data Analytics
Problem 1. For the survey data frame in the built-in MASS package, create a CART tree for Height using all other variables as predictors.
–tree <- rpart(Height ~ ., data = survey)
–This trick (using “~.,”) is also useful for regression when there are many columns/variables
Using your tree, what is the expected Height for a man with NW.Hnd = Wr.Hnd = 17 cm?
(Answer in number format e.g., 55)
Flag question: Question 2Question 210 pts
Problem 2. Use the randomForest package to create importance plots for predictors of acceleration (qsec) in the mtcars data set
What is the most important predictor of qsec according to the accuracy (“%IncMSE”) heuristic?
(Please copy the variable name from the plot e.g., cyl)
Flag question: Question 3Question 310 pts
Problem 3. For data frame mtcars, create a random forest PDP showing how qsecdepends on hp and wt
–Hint: Use rf <- randomForest(qsec ~., data = mtcars)
–Use “pdp <- partial(rf, pred.var = c(“hp”, “wt”), chull = TRUE)”
–Visualize results using plotPartial(pdp). (Include main = “qsec” to label your plot.)
Based on your PDP, the predicted (expected) weight of a car that is observed to have an acceleration time of qsec = 18.5 seconds (to reach ¼ mile) is closest to which of the following: 1, 2, 3, 4, 5 thousand pounds? (Please input the number in the blank)