# Predict the first observations of a time series when order of the model is higher

Suppose you have you have a time series with 365 observations, one for each day of the year, and you split the first 183 rows in training set and the latest 182 in test set.

Suppose you create an AR (autoregressive model), and you set the order of the model to 4. So you will have:

$$y(t) = a1y(t-1)+a2y(t-2)+a3y(t-3)+a4y(t-4)$$

In a situation like this, is it possible to do predictions on the first observation of the test set? That basically is the 184th row I think no, because we do not have y(t-1),...,y(t-4) but we have only y(t)=value of 184th observation.

So, the first row we can predict is 188th, right? Because:

$$y(t-1)=value$$ of $$187^{th}$$ row
$$y(t-2)=value$$ of $$186^{th}$$ row
$$y(t-3)=value$$ of $$185^{th}$$ row
$$y(t-4)=value$$ of $$184^{th}$$ row

I think that until now is right. Correct me if I am wrong.

But if I want to predict the obs. 184, the first one of test set, is there any way? I mean, without decreasing the order of the model from 4 to 1 for example.

The obvious answer is to use the last 4 data points of your training dataset. Note that there is no harm or bias in doing it. The purpose of breaking the data set into training and test datasets is to estimate and forecast on different datasets.

In your model, the dependent variable is $$y_5$$ to $$y_{183}$$. On the other hand, the four explanatory variables are: $$y_1-y_{179}$$; $$y_2-y_{180}$$; $$y_3-y_{181}$$; and $$y_4-y_{182}$$.

So the test data set for each of the explanatory variable actually starts from $$y_{180}$$, $$y_{181}$$, $$y_{182}$$ and $$y_{183}$$ respectively.

Therefore, by using the last four data points of your train dataset, you are not introducing any bias in terms of revalidating the model on fitted data.

• when you say "The obvious answer is to use the last 4 data points of your test dataset." you mean training, right? But why, I am not introducing any bias in doing it? Mar 16 at 10:08
• Oh yes. Sorry for the error. Yeah you are not. Because you need to see those last three data points as explanatory variables not dependent variables. Mar 16 at 10:12
• So, finally, if I want to predict the first obs of the test set, y(184) it will be equal to = a1y(183) + a2y(182) +a3y(181) + a4y(180) with 180 to 183 belonging to training set, without introducing bias Mar 16 at 10:14
• Yes. A more deeper way of looking at it (and more clearer also) is to transform the model in state space representation and then split the data into training and test. You will be able to clearly see that you are using test data only - and thus no bias. Mar 16 at 10:19
• Ok, thank you Dayne! Mar 16 at 10:22