SVM regression on time series, is there a lag?

1 min read

It would be nice if we can predict the future. For example, give the following time series, can we predict the next point?

Let’s use SVM regression, which is said to be powerful. We use the immediate past data point as the predictor. We train our model with the first 70% of data. Blue and Black are actual data, and Red and Pink are predicted data.

The prediction in general matches the trend. But if you look closely, you see that the predicted data is always lagging the actual data by one time step. See a zoom in below.

Why does this lag come from?

Let’s plot the predictor and the predicted (i.e. the current data point vs the next data point):

It looks normal to me.

It took me a few hours to think about this. Well, the reason turns out to be simple. It’s because our SVM model is too simple (only taking the last data point as predictor): if a data has a increasing trend, then the SVM model, which only consider the immediate history, will give a high predicted value if the current data value is high, a low value if the current data value is low. As a consequence, the predicted value is actually more similar to the current value – and that gives a lag if compared to the actual data.

To reduce the lag, you can build a more powerful SVM model – say use the past 2 data points as the predictor. It will make a more reliable prediction – if the data is not random. See below comparison: you can easily see the lag is much smaller.

Source code can be downloaded here test_svr. Part of the source code is adapted from http://stackoverflow.com/questions/18300270/lag-in-time-series-regression-using-libsvm


Receive email notification via email 博客有新内容通知我
文献鸟,永远不错过新文献!

Don't want to miss new papers in your field? Check out Stork we developed:


第二十六期 fNIRS Journal Club 视频

来自上海精神卫生中心的胡志善博士为大家介绍了一篇他们去年发表的综述(静息态近红外在研究发育的应用)。视频如下: Youtube:https://youtu.be/C7xIRrBUhhg Youku: https://v.youku.com/v_show/id_XNTgzNTQ5ODg3Mg==.html
Xu Cui
4 sec read

第二十六期 fNIRS Journal Club 通知 2022/1/15,10:00am

来自上海精神卫生中心的胡志善博士将为大家介绍具体一篇他们去年发表的综述(静息态近红外在研究发育的应用)。热烈欢迎大家参与讨论。 时间: 北京时间2022年1月15日上午10:00地点: https://zoom.com房间号: 897 8179 5073密码: 333858 胡博士要讲解的文章如下: Hu, Liu, Dong, Niu (2020) Applications of Resting-State fNIRS in the Developing Brain: A Review...
Xu Cui
6 sec read

第二十五期 fNIRS Journal Club 视频

来自华东师范大学的胡银莹博士为大家介绍了具体如何计算和验证超扫描实验中脑间同步性,并分享做fNIRS实验相关方面的应用经验。视频如下: Youtube:https://youtu.be/xI_6wKd06io Youku:上传后被youku屏蔽,原因不详。
Xu Cui
3 sec read

8 Replies to “SVM regression on time series, is there a lag?”

  1. Hi Mr Cui,
    I have found the same situation that you described here in this post.
    I tried to add more data points before the day that I want to predict, despite that the lag is still there. How is possible that? I have to change in manual way some weights in the the SMV Function about these previous data in order to obtain a future value?

  2. Hi Xu Cui,

    1)Which part of your source codes correspond to the lag reduction?
    2)What if my data do not have a trend? If it’s random, can the code be used to reduce the lag?

Leave a Reply

Your email address will not be published. Required fields are marked *