Question: R - Studio Lab Homework: Set seed to 1 first by executing set.seed ( 1 ) command. Include relevant code for each problem. Include the

R-Studio Lab Homework:
Set seed to 1 first by executing set.seed(1) command.
Include relevant code for each problem. Include the output where necessary
1. This question should be answered using the Weekly data set, which is part of the ISLR
package. This data is similar in nature to the Smarket data, except that it contains 1,089
weekly returns for 21 years, from the beginning of 1990 to the end of 2010. Please
include necessary output with code for each problem.
a. Fit Logistic regression model using a training data period from 1990 to 2008 with
Direction as response and the five lag variables plus Volume as predictors.
Include the confusion matrix below and calculate the accuracy and misclassification
rate for the test data (that is, the data from 2009 and 2010).
Include all relevant codes. Relevant codes are creation of training and test data to
fitting the model to obtaining the probabilities of success and creating the confusion
matrix.
b. Fit LDA model using a training data period from 1990 to 2008 with Direction as
response and the five lag variables plus Volume as predictors.
Include the confusion matrix below and calculate the accuracy and misclassification
rate for the test data (that is, the data from 2009 and 2010).
Include all relevant codes.
c. Repeat (a) using KNN. First find optimal k using 10-fold cross-validation. Then use
the optimal k to fit the knn model on the test data and then calculate the appropriate
confusion matrix. Include your confusion matrix below.
Include all relevant codes.
Which of the three methods (Logistic, LDA and KNN) offer the better test accuracy
and least test error rate?

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!