Question: How to solve this question by using R Language? You can attach the Boston data set in the MASS package. library(MASS) attach(Boston) For the Boston

How to solve this question by using R Language?

You can attach the Boston data set in the MASS package.

library(MASS)

attach(Boston)

For the Boston data set, we are interested in predicting whether a given suburb has a

crime rate above or below the median given other information in the data.

(a) Conduct the logistic regression analysis using all the predictors. To do the pre-

diction, use the first 405 rows as the training set and the rest as the test set.

Describe your result, include the error table and report the test error rate.

(b) Employ the LDA method using all the predictors. To do the prediction, use the

first 405 rows as the training set and the rest as the test set. Describe your result,

include the error table and report the test error rate.

(c) Employ KNN method using all the predictors. To do the prediction, use the first

405 rows as the training set and the rest as the test set. Use 5 fold cross-validation

to choose k by splitting the training set into 5 equal-sized subsets. What is the

optimal value of k? Describe your result, include the error table and report the

test error rate.

(d) Which method is the best? Logistic regression, LDA or KNN? Why?

(e) For the logistic regression in (a), perform forward and backward model selections

[Hint: you can use the step() function in R]. Repeat (a) using only the selected

predictors. Compare the full model and selected model(s), which model is better

and why?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!