I'm new to R, and was wondering if any of you could help me out with the code to make a predicted vs actual graph. I am trying to predict the direction of stock price movements using a GLM Logit Model. Your help will be appreciated.
cat("\014");
library(readxl);
Smarket = read_excel("C:/Users/Sohaib/Desktop/data.xlsx");
# Download introduction to statistical learning package
library(ISLR)
# Define train and test sample
train = (Smarket$year<2019)
test = Smarket[!train,]
# Fitting the LR model on the data
fit = glm(direction ~ lag1 + open + high + low , data=Smarket, family=binomial, subset=train)
# Predicting against test data
prob = predict(fit, test, type="response")