The data was organized in a data table as [<date>; <x1>; <x2>; <y>]. To build the auto-regressive model, I wanted to use the "Polynomial Regression (Learner)" node. This node models y by using a polynomial regression of y on (x1, x2). Notice that the x1, x2, and y values used for the regression belong to the same data row, that is to the same date.
The issue then is to introduce the past values of x1 and x2 in the regression model.
To do that, we built N-1 data columns x1(t), x(t+1)... x1(t+N-1), and N-1 data columns x2(t), x(t+1), ... x2(t+N-1) and we used them to build the regression model for y(t+N).
To make the description of the procedure more clear, let's fix N = 3.
We then built a data set structured as:
<date>; <x1(t+0)>; <x1(t+1)>; <x1(t+2)>; <x2(t+0)>; <x2(t+1)>; <x2(t+2)>; <y(t+3)>
The polynomial regression was then run using <y(t+3)> as the target variable and <x1(t+i)>, <x2(t+i)> as the modelling variables. Below is the picture of the workflow used to do time series prediction with an auto-regressive model. "Past and Future" is the metanode that manipulate the data to obtain the desired structure.
iteration 0: 0, 1, 2, ..., n rows -1
iteration 1: -1 0, 1, ..., nrows - 2
iteration 2: -2, -1, 0, ..., nrows -3
The following figure shows the data table obtained at iteration number 2.
At each iteration column x1 and x2 are renamed as x1(t+<iteration no>) and x2(t+<iteration no>).
I used this workflow to perform an autoregressive model for y. However, the same data table structure can be used for any time series prediction schema, using for example a neural network or any other quantitative predictive algorithm available in KNIME.