Answered step by step
Verified Expert Solution
Link Copied!

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

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions