Shifting the series by 1 lag: What is its relevance?

  Course Name: Financial Time Series Analysis for Trading, Section No: 14, Unit No: 1, Unit type: Notebook



After forecasting the predicted values using rolling function, what is the need to shift the predicted values by 1 lag.


Predict the price

df['Pred_Price'] = df['Value'].rolling(train_test_window).apply(predict_price_AR)



Shift the previous value 

df['Pred_Price_1'] = df['Pred_Price'].shift(1)

Hi Tanul,



Consider the scenario, if you want to predict todays price, what will you do? You will predict it based on the price till yesterday. You will not have today's price to make the prediction. Or if you already have today's price, you dont need to make prediction.



In the example above, we are training the model to make the prediction at current time based on previous time. But what happens here is that the predicted value is recorded corresponding to the last used value to make the prediction. Hence we shift it by 1 period so that it corresponds to next time stamp. Like, if we use value 1 to value 10 to make predictions, it will be recorded against time 10. Therefore we shift it by 1 period, that is to time 11.



Hope this helps.



Thanks!

Thanks. 

That was clear.