Matching symbols with predictions in the predict function

Hello Dr. Ballings,

Can you explain what the model function should return?
It seems to me as though this function should not only
return the model but symbols as well so that the predict
function can output symbols and the predictions
corresponding to them. Is this correct? If so, can you
explain the best approach to take so that this is
achieved? As of now, my predict function only returns
predictions but not the symbols corresponding to them.
I tried to return a list within my model function but the
predict function does not work on list. If you can provide
a clear explanation as to how I can match my
predictions with their corresponding symbols within the
model function so that the predict function recognizes them
I would appreciate it.

Thank you,
Shelby H.

Answers and follow-up questions

Answer or follow-up question 1

Dear Shelby,

The modelbuilding() function should return a model. It can also return the maximum date found in the data. It should not output symbols or
How will it be used?
Suppose wel call modelbuilding() today and store the output on disk. We would then close R. We would then call the predict function in the
future (e.g., next month) after loading the model from disk.

The predict function should return predictions and symbols in a data frame. You simply read in the data in your predict function, make a
prediction and return all the symbols you read in along with the predictions in the same order as the data.

Michel Ballings

Sign in to be able to add an answer or mark this question as resolved.