2
$\begingroup$

I'd like to know how to use cross-validation for time series analysis using a regression-based approach without incurring in under- or over-fitting. In particular, assume we have an input time series $u$ and an output time series $y$, both of size $n$. Also assume that we want to obtain a regression model of the form ${ y }_{ t }={ \alpha }_{ 1 }{ y }_{ t-1 }+{ \alpha }_{ 2 }{ y }_{ t-2 }+{ \alpha }_{ 3 }{ u }_{ t-5 }+{ e }_{ t }$. Therefore we build a system of equations of the form $Ax=b$, where:

$A=\begin{bmatrix} { y }_{ 5 } & { y }_{ 4 } & { u }_{ 1 } \\ { y }_{ 6 } & { y }_{ 5 } & { u }_{ 2 } \\ \vdots & \vdots & \vdots \\ { y }_{ n-1 } & { y }_{ n-2 } & { u }_{ n-5 } \end{bmatrix}$ $b=\begin{bmatrix} { y }_{ 6 } \\ { y }_{ 7 } \\ \vdots \\ { y }_{ n } \end{bmatrix}$ $x=\begin{bmatrix} { \alpha }_{ 1 } \\ { \alpha }_{ 2 } \\ { \alpha }_{ 3 } \end{bmatrix}$

How should I split the data into training and testing sets for cross-validation given the high dependency within the data?

$\endgroup$
2
  • $\begingroup$ splitting of training and test sets, and cross-validation of time series is covered in section 2.5 of Hyndman and Athana­sopou­los otexts.org/fpp/2/5 (same author, different article than the one referred to by Chris) $\endgroup$
    – zbicyclist
    Commented Feb 4, 2015 at 4:02
  • $\begingroup$ Thanks for your reply @zbicyclist . I just checked the reference that you mentioned. For me it sounds pretty similar to the idea of expressing the time series as a system of equations $Ax=b$ as I mentioned above, but maybe I'm misinterpreting it. $\endgroup$ Commented Feb 4, 2015 at 21:02

1 Answer 1

3
$\begingroup$

I don't believe there is any principled answer to this without considering the problem domain. As you pointed out, there may be strong temporal dependencies within the dataset, and there's no obvious way to avoid these. You could try to select training and testing portions which are temporally separated from one another by some buffer zone, but this will require making assumptions about the timescale of the temporal dependencies.

As discussed by Rob Hyndman, one way of measuring model accuracy is one-step-ahead prediction, e.g. fit to timepoints 1-T, then predict $y_{T+1}$ using your model. This doesn't necessarily tell you about generalization performance (e.g. on totally new datasets) but is at least a good within-dataset measure of performance.

In a real application, you will typically have multiple timecourses which are (hopefully) independent, allowing you to cross-validate over different splits.

$\endgroup$
2
  • $\begingroup$ Good point about one-step-ahead. If it makes substantive sense, you could extend that to leave-one-out cross-validation $\endgroup$ Commented Feb 4, 2015 at 4:31
  • $\begingroup$ Thanks Chris! I followed your advise but the cross-validation error curve sometimes has local minima as described here. Have you deal with something similar before? $\endgroup$ Commented Dec 15, 2015 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.