# Time series forecasting using Support Vector Machines

I have been trying to use Support Vector Machine method for time series forecasting. I have seen allot of research papers, but nobody shared the code or tool they have used for that. Got some materials from KU Leuven. " LS-SVMlab Toolbox User’s Guide version 1.7" using the code in the page 34 section 3.3.8."

The problem is it cannot predict accurately.

It would be great if anybody can share the code for the problem and the software for that.(Matlab/R etc).

## Attaching here the Matlab output and code i have used.

% load time-series in X and Xt

lag = 50;

Xu = windowize(X,1:lag+1);

Xtra = Xu(1:end-lag,1:lag); %training set

Ytra = Xu(1:end-lag,end); %training set

Xs=X(end-lag+1:end,1); %starting point for iterative prediction Cross-validation is based upon feedforward simulation on the validation set using the feedforwardly trained model:

[gam,sig2] = tunelssvm({Xtra,Ytra,’f’,[],[],’RBF_kernel’},’simplex’,... ’crossvalidatelssvm’,{10,’mae’}); Prediction of the next 100 points is done in a recurrent way:

[alpha,b] = trainlssvm({Xtra,Ytra,’f’,gam,sig2,’RBF_kernel’});

%predict next 100 points

prediction = predict({Xtra,Ytra,’f’,gam,sig2,’RBF_kernel’},Xs,50);

plot([prediction Xs]);

• Possible duplicate of this post. Mar 9, 2015 at 17:52

• Previous predictions (especially $x_{t-1}$)
• Movement of the distribution (e.g. $(x_{t-1} - x_{t-2})/x_{t-1}$ or PID)