# matlab - Prediction of data using regression for time series

itPublisher 分享于

I try to prepare the data for regression with time series analysis. I use LIBSVM on Matlab

Say I have N days of price and I want to predict the next day's price. The training set X is thus a vector of vectors of length K, and the training set Y are like:

(DAY 1).....(DAY 2).....(DAY K)-------->DAY (K+1)

(DAY 2).....(DAY 3).....(DAY K+1)------>DAY (K+2)

(DAY 3).....(DAY 4).....(DAY K+2)------>DAY (K+3)

so on...

But the problem is: I assume the test data solution will give me the days of DAY (K+1),DAY (K+2),DAY (K+3). But it always fits the last day of Independent variables. (Here they are (DAY K), (DAY K+1), (DAY K+2)).

I tried to change the value of K but it didn't change.

To explain more: As an example, suppose we have the following univariate time series s :

1 2 3 4 5 6 7 8 9 =s..s

Windowizing using N=3 yields:

[s[k−3], s[k−2], s[k−1]] →s[k]

⎢1 2 3 ⎢ ⎢4⎢

⎢2 3 4 ⎢ ⎢5⎢

⎢3 4 5 ⎢ ⎢6⎢

⎢. . . ⎢ ⎢.⎢

⎢6 7 8 ⎢ ⎢9⎢

But the problem is the result fits the vector ⎢3⎥ ⎢4⎥ ⎢5⎥ ... ⎢8⎥

I couldn't find where the problem is?

matlab time-series libsvm prediction
|
this question
asked Aug 28 '13 at 19:20 user2602256 3 3 1   It's not a general problem, but probably a problem with your code. You should attach some of the code so we can understand where the problem is. –  Adiel Aug 28 '13 at 19:32      n=3 dataTrainIndependent=dataTrainIndependent(:,2); dataTrainIndependentOrj=dataTrainIndependent; dataTrainIndependent=dataTrainIndependent(1:end-n); for i=1:n; dataTrainIndependent=[dataTrainIndependent dataTrainIndependentOrj(1+i:end-(n-i),:)]; end; dataTrainDependent(1:n,:)=[]; %%%%also same for test data and made scale here cmd = ['-s 4 -t 2']; model = svmtrain(dataTrainDependent, dataTrainIndependent, cmd); [predictedValue, acc, dec] = svmpredict(dataTestDependent, dataTestIndependent, model); [MSE DA CP CD]=calculate(dataTestDependent,predictedValue); –  user2602256 Aug 28 '13 at 19:48 1   add code to the question, comments dont format it well –  lejlot Aug 29 '13 at 8:21      Without code it's hard to tell where problem is. One possibility is that the time-series is sufficiency difficult to predict that the best available estimate is the "persistence forecast", although that would not be the case if you tested it with the `1:9` example suggested in the question. –  kabdulla Aug 27 '16 at 0:30

|  ×
• 登录
• 注册

×

### 请激活账号  