Answered step by step
Verified Expert Solution
Question
1 Approved Answer
R - Studio Lab Homework: Set seed to 1 first by executing set.seed ( 1 ) command. Include relevant code for each problem. Include the
RStudio Lab Homework:
Set seed to first by executing set.seed command.
Include relevant code for each problem. Include the output where necessary
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
weekly returns for years, from the beginning of to the end of Please
include necessary output with code for each problem.
a Fit Logistic regression model using a training data period from to 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 and
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 to 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 and
Include all relevant codes.
c Repeat a using KNN First find optimal k using fold crossvalidation. 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
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