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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started