I am using the R programming language to try and write a routine that calculates the training errors of different time series models.
The code below seems to run, but