0

I am new to R and data analysis in general and need some help with machine learning.

I created a plot and some linear models of the closing prices of two stocks. These prices are the monthly prices for a range of years. I am seeing if the price of stock A predicts stock B. I want to input random closing data from the weekly prices to test the models.

Given that the weekly data has the predictor price A and the resultant price B, how would I see if my model is accurate for this randomized weekly data/ that it is accurate to the real world?

  • 1
    The `predict` function is normally used if the question is understood correctly. I added an example to the [documentation page that illustrates its use](http://stackoverflow.com/documentation/r/801/linear-models-regression#t=201612052049360101522) – Pierre L Dec 05 '16 at 20:50
  • It seems like predict is what I was looking for. How though do I see the accuracy of the predict? – user6912880 Dec 05 '16 at 21:04
  • You have to choose which metric of accuracy you want to use. Most people use [the root-mean-square-error](http://stackoverflow.com/questions/17703037/how-to-perform-rmse-in-r) – Pierre L Dec 05 '16 at 21:26

1 Answers1

0

It is hard to tell without an example of your data and the code you wrote but here is one advice: remove some data before fitting your model and use it later to test how well/bad your model predict those values using the function "predict". Hope that will help you moving forward.

Valentine
  • 41
  • 6
  • Hi! Thanks for taking the time, but this this doesn’t qualify for a good answer. Please [learn How to write a good answer](http://stackoverflow.com/help/how-to-answer). Remember that you can always use the comment section to provide comments. – JoakimE Dec 05 '16 at 22:06