1
$\begingroup$

I'm currently working with cv.glmnet and it is my understanding that you should not use normal cross validation for time series data. Is it possible to use the foldid argument with cv.glmnet in order to accomplish cross validation with time series data?

$\endgroup$
1
$\begingroup$

No, it won't be reasonable to use cv.glmnet for cross validation on time series data. A good explanation how CV should look like on time series data can be found here:

https://robjhyndman.com/hyndsight/tscv/

In short, a standard CV would skip time points randomly and thus destroy the temporal relationships you want to identify. (I assume that your samples are your time points, since you didn't give details on your data.)

They recommend to use the forecast package in R. Unfortunately, I don't know of a LASSO implementation of cross validation for time series data.

$\endgroup$
1
  • $\begingroup$ Note that forecast is now deprecated in favour of the tidyverts family of packages $\endgroup$ – Hong Ooi Feb 14 '20 at 11:29
0
$\begingroup$

For time series cross validation, you can use caret library in R.

See the following for further reference.

https://topepo.github.io/caret/data-splitting.html

https://rpubs.com/crossxwill/time-series-cv

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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