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



写作助手,把中式英语变成专业英文


Want to receive new post notification? 有新文章通知我

第五十期fNIRS Journal Club通知2024/03/30, 10am 王一晖

早期的 STEM 教育对于以后的学习至关重要。现有研究尚未就STEM教学法达成共识,学生先验知识对基于故事的STEM教学法的影响还有待探讨。来自澳门大学张娟教授团队的王一晖将会分享基于fNIRS超扫描
Wanling Zhu
9 sec read

第四十九期fNIRS Journal Club视频 高倩博士

Youtube: https://youtu.be/a2QlCFZUytA优酷: https://v.youku.com/v_show/id_XNjM3MjMyNjUxMg==.html 竞技比赛中,
Wanling Zhu
12 sec read

第四十九期fNIRS Journal Club通知2024/02/24, 10am 高倩博士

竞技比赛中,特别是需要注意高度集中的射击项目中,如何保持稳定的注意控制对运动员的表现至关重要。近期的一项研究调查了赛前短时正念练习是否对运动员在射击比赛中的注意控制具有提升作用。来自北京体育大学心理学
Wanling Zhu
9 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 Xu Cui Cancel reply

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