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 视频

546个被试的大型实验是怎么做的?近红外超扫描技术如何揭开群体冲突的神经机制?北京时间2020年5月29日周五上午11点,北京师范大学的马燚娜教授(Yina Ma)为大家讲解了她们组刚刚在Nature Neuroscience发表的文章。下面是报告视频。第一个是在Youtube,第二个是在youku。 Youtube:https://www.youtube.com/watch?v=4qZ7zP-BGz4Youku:https://v.youku.com/v_show/id_XNDY5MTc0MjAxMg==.html 她讲的文献如下: Within-group synchronization in the prefrontal cortex associates with intergroup conflict. Nature neuroscience https://www.storkapp.me/pubpaper/32341541 中文摘要(人工智能翻译,仅供参考):陷入群体的个人有时会失去自己的个性,冒着通常会避免的风险,以无端的敌对态度与外界接触。在这项研究中,我们确定了右侧背外侧前额叶皮层(rDLPFC)和右侧颞顶交界处(rTPJ)的组内神经同步是组间敌对性的潜在机制。我们将546个人组织为91个三对三人小组间比赛,诱导了组内亲和,并使用功能性近红外光谱仪测量了神经活动和组内同步。在组内亲和之后,个人给组内成员的钱比给组外成员的钱多,并且捐出更多的钱来击败竞争对手。组内亲和减少了rDLPFC的活动,并增加了rDLPFC和rTPJ之间的功能连接。尤其是在组外攻击期间,组内亲和还增加了rDLPFC和rTPJ中的组内同步,并且组内rDLPFC同步与组间敌对性正相关。组内同步减少前额活动可能可以解释组内联结如何导致对外界的冲动和集体敌视。
Xu Cui
13 sec read

Remote fNIRS

Everytime I met Dr Leanne Hirshfield, I am impressed by her energy and passion with the fNIRS technology. It was a pleasure listening to...
Xu Cui
4 min read

fNIRS Journal Club 通知 2020/5/29, 11am

546个被试的大型实验是怎么做的?近红外超扫描技术如何揭开群体冲突的神经机制?北京时间2020年5月29日周五上午11点,北京师范大学的马燚娜教授(Yina Ma)将为大家讲解她们组刚刚在Nature Neuroscience发表的文章。 欢迎大家参加并参与讨论。 时间: 北京时间2020年5月29日周五上午11点 地点: https://zoom.com/j/84320310196房间号: 843 2031 0196 密码: 600516 她要讲的文献如下: Within-group synchronization in the prefrontal cortex associates with intergroup conflict....
Xu Cui
7 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 to Nabiil Aujeemuddee Cancel reply

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