This question should be answered using the Weekly data set, which is part of the ISLR package. Weekly percentage returns for the S&P 500 stock index between 1990 and 2010. (To learn more about the data in the help section in R search for Weekly S&P Stock Market Data).
a. Produce some graphical summaries of the Weekly data. Do there appear to be any patterns?
b. Use the full data set to perform a logistic regression with Direction as the response and the five lag variables plus Volume
as predictors. Use the summary function to print the results. Do any of the predictors appear to be statistically significant? If so, which ones?
c. Split the sample between training and test data and evaluate the forecast accuracy of the model from part b). Compare the forecast accuracy with the model that includes Lag 2 as the only predictor. (To do this part you need to apply cross validation method). Which model would you choose to predict the Direction of weekly returns?
Please share all code