Question: This Question Should Be Answered Using The Weekly Dataset, Which Is Part Of The ISLR Package. This Data Is Similar In Nature To The SMarket
This Question Should Be Answered Using The Weekly Dataset, Which Is Part Of The ISLR Package. This Data Is Similar In Nature To The SMarket Data Used In Section 4.6 Of Out Textbook, Except That It Contains 1,089 Weekly Returns For 21 Years, From The Beginning Of 1990 To The End Of 2010. (A) Use The Full Dataset To Perform A Logistic Regression With Direction
Please only answer question (f) (g) (h)
Please only answer question (f) (g) (h)
This question should be answered using the Weekly dataset, which is part of the ISLR package. This data is similar in nature to the SMarket data used in section 4.6 of out textbook, except that it contains 1,089 weekly returns for 21 years, from the beginning of 1990 to the end of 2010. (a) Use the full dataset to perform a logistic regression with Direction as the re- sponse and the five lag variables plus Volume as predictors. Call your model glm.fit. Use the summary function to print the results. Do any of the predictors appear to be statistically significant? If so, which ones? (b) Use the following code to produce the confusion matrix for this problem. = > glm.probs predict (glm.fit, type = "response") > glm.pred rep("Down", length (glm. probs)) > glm.pred [glm.probs > 0.5] = "Up" > table (glm.pred, Weekly $Direction) Explain what the confusion matrix is telling you about the types of mistakes made by logistic regression. (c) Now fit the logistic regression model using a training data period from 1990 to 2008, with Lag1, Lag2, and Lag3 as the only predictors. Compute the confusion matrix and the overall fraction of correct predictions for the held out data (that is, the data from 2009 and 2010). (d) Repeat (c) using LDA. Use library (MASS) to work with the lda () command. (e) Repeat (c) using KNN with K 1. Invoke library (class) to work with the knn () command. Set your seed to 2016 via set. seed (2016). = (f) Which of the models from parts (c), (d), and (e) appears to provide the best results on this data? (g) What is one scenario in which you might expect an LDA model to outperform a logistic regression model? (h) What is one scenario in which you might expect a KNN model to outperform a logistic regression model?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
