Class TimeSeriesFilter
- All Implemented Interfaces:
Serializable
Class TimeSeriesFilter can be used to operate on a data matrix and lags every
column to form a new data matrix. Using the method computeLags, each column of the input matrix,
x, is transformed into (nLags+1) columns by
creating a column for \(\text{lags} = 0, 1, \ldots \text{nLags}\).
The output data array, z, can be symbolically represented as:
$$z = | x(0) : x(1) : x(2) : \ldots : x(\text{nLags}-1) |,$$
where x(i) is a lagged column of the incoming data matrix,
x.
Consider, an example in which x has five rows and two columns with all variables
continuous input attributes. Using nObs and nVar to represent
the number of rows and columns in x, let
$$x = \left[ \begin{array}{cc}
1 & 6 \\
2 & 7 \\
3 & 8 \\
4 & 9 \\
5 & 10 \\
\end{array} \right]$$
If nLags=1, then the number of columns in z[][] is
nVar*(nLags+1)=2*2=4, and the number of rows is
(nObs-nLags)=5-1=4:
$$z = \left[ \begin{array}{cccc}
1 & 6 & 2 & 7\\
2 & 7 & 3 & 8 \\
3 & 8 & 4 & 9 \\
4 & 9 & 5 & 10 \\
\end{array} \right]$$
If nLags=2, then the number of rows in z will be
(nObs-nLags)=(5-2)=3 and the number of columns will be
nVar*(nLags+1)=2*3=6:
$$z = \left[ \begin{array}{cccccc}
1 & 6 & 2 & 7 & 3 & 8\\
2 & 7 & 3 & 8 & 4 & 9 \\
3 & 8 & 4 & 9 & 5 & 10 \\
\end{array} \right]$$
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[][]computeLags(int nLags, double[][] x) Lags time series data to a format used for input to a neural network.
-
Constructor Details
-
TimeSeriesFilter
public TimeSeriesFilter()Constructor forTimeSeriesClassFilter.
-
-
Method Details
-
computeLags
public double[][] computeLags(int nLags, double[][] x) Lags time series data to a format used for input to a neural network.- Parameters:
nLags- Anintcontaining the requested number of lags.nLagsmust be greater than 0.x- Adoublematrix, nObs by nVar, containing the time series data to be lagged. It is assumed thatxis sorted in descending chronological order.- Returns:
- A
doublematrix with (nObs-nLags) rows and (nVar(nLags+1)) columns. The columns 0 through (nVar-1) contain the columns ofx. The next nVar columns contain the first lag of the columns inx, etc.
-