- This topic has 3 replies, 2 voices, and was last updated 7 years, 10 months ago by
hessinemaaoui.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
June 17, 2013 at 2:59 pm #1949
hessinemaaoui
KeymasterHi,
I am a newer of SuanShuers and I want to use ARIMA model in SuanShu to forecast next value of time series just like last topic “ARIMA forecast”. After reading the reply of last topic, I have a try using my own data and the codes are listed below. However, some new questions appear.My Data:
1234567891011121314151617181.5959709882736206 <br />0.7300914525985718 <br />2.0011744499206543 <br />3.6755871772766113 <br />0.8066112399101257 <br />1.3413848876953125 <br />3.371157646179199 <br />0.4400146007537842 <br />2.637667655944824 <br />2.1453769207000732 <br />2.341433048248291 <br />2.3429665565490723 <br />1.1187453269958496 <br />1.4169363975524902 <br />3.328829050064087 <br />4.157748699188232 <br />3.9255290031433105 <br />2.7843635082244873Source Code:
12345678910111213141516171819202122232425262728try{<br />//read time series from file to ArrayList<br />BufferedReader br = new BufferedReader(new FileReader("arimademo.txt"));<br />String line = null;<br />ArrayList arr = new ArrayList();<br />while((line = br.readLine()) != null){<br />arr.add(Double.valueOf(line));<br />}<br />//get the last value<br />double last = arr.get(arr.size()-1);<br />//remove last value<br />arr.remove(arr.size()-1);<br />//new a double array<br />double[] series = new double[arr.size()];<br />for(int i = 0; i < arr.size(); i++){<br />series<i> = arr.get(i);<br />}<br />//build ARIMA model and then forecast next value<br />ConditionalSumOfSquares instance = new ConditionalSumOfSquares(series, 1, 1, 1);<br />ARIMAModel arima = instance.getModel();<br />ARIMAForecastMultiStep forecast = new ARIMAForecastMultiStep(new SimpleTimeSeries(series), arima, 1);<br />System.out.println("prediction = "+forecast.xHat());<br />System.out.println("error = "+forecast.var());<br />System.out.println("real = "+last);<br />br.close();<br />}catch(Exception e){<br />e.printStackTrace();<br />}</i>and the output is:
123prediction = 4.246483542430577<br />error = 0.603935593121584<br />real = 2.7843635082244873My questions are:
1. the forecast accuracy is too low, prediction value is 4.246 but real value is 2.78
2. how to determine p,d,q automatically?
3. why error != |real-prediction|?Thanks for your kindly attention and Waitng for your help.
-
AuthorPosts
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.