Linear
Regression
Linear Regression (via analyticsvidhya.com)
To being, random "seeds" will be generated using the function
set.seed(). This allows for random numbers or pseudorandom
numbers to be generated using an algorithm. The point of this
function is to sample without reproducing the same number twice.
Random Seed
Next, a training and testing dataset are created and put into data
frames using our random seeds. This ensures there are two
different set of dates to sample from when running our
regression model and making predictions.
Training and Testing Datasets
This is where the training dataset gets put to work and the
regression model, using the lm() function trains the dataset in order
to calculate trends. For this regression model, the opening and
closing prices were used to compare with each other in order to
train the model to be ready to input into the prediction model.
Train Model