[英]Lag in time series regression using LibSVM
I use libSVM
in Matlab to examine the utility of SVM
regression for time series prediction. 我在Matlab中使用
libSVM
来检查SVM
回归用于时间序列预测的效用。 I use the following code sample: 我使用以下代码示例:
t = -10:0.1:10;
x = 2*sin(10*t)+0.5*t.^2+4;
x = (x - min(x)) / (max(x) - min(x));
x = x';
data = x(1:end-1);
dataLabels = x(2:end);
trainDataLength = round(length(data)*70/100);
TrainingSet = data(1:trainDataLength);
TrainingSetLabels = dataLabels(1:trainDataLength);
TestSet = data(trainDataLength+1:end);
TestSetLabels = dataLabels(trainDataLength+1:end);
options = ' -s 3 -t 2 -c 100 -p 0.001 -h 0';
model = svmtrain(TrainingSetLabels, TrainingSet, options);
[predicted_label, accuracy, decision_values] = svmpredict(TestSetLabels, TestSet, model);
figure(2);
plot(1:length(TestSetLabels), TestSetLabels, '-b');
hold on;
plot(1:length(TestSetLabels), predicted_label, '-r');
hold off;
and the figure I get is: 我得到的数字是:
from the figure it can be seen that there is a lag in predicted values vs. actual values. 从图中可以看出,预测值与实际值之间存在滞后。 I don't know if this lag is because of some bug in my code, in
libSVM
code, or that it is natural, and we cannot expect to predict one-step ahead value of the time series. 我不知道这种滞后是由于我的代码,
libSVM
代码中的某些错误,还是自然的,我们不能期望预测时间序列的提前值。
What you do in this line 你在这行做什么
model = svmtrain(TrainingSetLabels, TrainingSet, options);
Is to ask to estimate y=TrainingSetLabels with the features contained in x=TrainingSet. 是要使用x = TrainingSet中包含的功能来估计y = TrainingSetLabels。
Given your code, there is a one timestep lag between x and y, so the behavior is normal. 给定您的代码,x和y之间存在一个时间步长滞后,因此行为是正常的。 However, you can improve your estimation.
但是,您可以改善估计。 x can be a matrix, with one column per feature vector.
x可以是矩阵,每个特征向量一列。 What can do is to add the following columns :
可以做的是添加以下几列:
This way (mostly with the N time step lag column), you will be able to really anticipate the incoming values. 这样(通常使用N个时间步滞后列),您将能够真正预期输入的值。
Cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.