Free Statistics

of Irreproducible Research!

Author's title

Author*Unverified author*
R Software Modulerwasp_arimaforecasting.wasp
Title produced by softwareARIMA Forecasting
Date of computationMon, 15 Dec 2008 12:00:45 -0700
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2008/Dec/15/t1229367819bsovikh6fe0a1er.htm/, Retrieved Wed, 15 May 2024 15:32:48 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=33786, Retrieved Wed, 15 May 2024 15:32:48 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact160
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
F       [ARIMA Forecasting] [step 1] [2008-12-15 19:00:45] [c00776cbed2786c9c4960950021bd861] [Current]
-   PD    [ARIMA Forecasting] [forecasting ] [2008-12-17 16:14:42] [3f66c6f083b1153972739491b89fa2dd]
Feedback Forum
2008-12-23 20:41:15 [Lana Van Wesemael] [reply
Dat je voorspelling telkens start bij 86 is normaal. Je tijdreeks bevat 94 waarden, als testing period heb je 12 genomen, de computer schrapt dus 12 periodes van je tijdreeks en begint vanaf die periode – de 86e dus – met de voorspelling.

Step 1: in deze stap had de student ook naar de eerste grafiek kunnen zien. Hieruit blijkt dat de voorspelling in de lijn ligt van de oude waarden, zelfs de schommeling die er voorheen in zat zit in de voorspelling. De voorspelling gedraagt zich dus zoals we verwachten.

Step 2: De voorspelde en werkelijke waarde liggen inderdaad zeer dicht bij elkaar. De werkelijke waarde doorbreekt ook nooit het betrouwbaarheidsinterval, wat natuurlijk goed is. Ik denk wel dat er invloed is van een trend. De voorspelde waarde zet immers de dalende trend van de oude observaties verder. Eveneens is er in de voorspelde waarde toch wel een sterke schommeling aanwezig.

Step 3: de standaardfout wordt groter naarmate men verder in de toekomst voorspelt, dit is vrij logisch. De standaardfout is echter wel opvallend laag. Bij de laatste maand bedraagt deze nog geen 9% wat toch wijst op een vrij goed model.

Step 4: dit heeft de student correct toegelicht. De kans op stijgingen zijn bij deze tijdreeks niet echt hoog. Dit is waarschijnlijk het geval omdat de tijdreeks een dalend verloop kent. Het is dus logisch dat de kans dat de voorspelde waarde groter gaat zien niet hoog is.

Step 5: Hier had de student naar de 2e grafiek moeten kijken. Hieruit blijkt dat de werkelijke waarde en de voorspelde waarde erg dicht bij elkaar liggen. Dit is consistent met de P.E. deze zijn immers steeds erg laag.

Post a new message
Dataseries X:
113438
109416
109406
105645
101328
97686
93093
91382
122257
139183
139887
131822
116805
113706
113012
110452
107005
102841
98173
98181
137277
147579
146571
138920
130340
128140
127059
122860
117702
113537
108366
111078
150739
159129
157928
147768
137507
136919
136151
133001
125554
119647
114158
116193
152803
161761
160942
149470
139208
134588
130322
126611
122401
117352
112135
112879
148729
157230
157221
146681
136524
132111
125326
122716
116615
113719
110737
112093
143565
149946
149147
134339
122683
115614
116566
111272
104609
101802
94542
93051
124129
130374
123946
114971
105531
104919
104782
101281
94545
93248
84031
87486
115867
120327
117008
108811
104519




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135

\begin{tabular}{lllllllll}
\hline
Summary of computational transaction \tabularnewline
Raw Input & view raw input (R code)  \tabularnewline
Raw Output & view raw output of R engine  \tabularnewline
Computing time & 2 seconds \tabularnewline
R Server & 'Gwilym Jenkins' @ 72.249.127.135 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=33786&T=0

[TABLE]
[ROW][C]Summary of computational transaction[/C][/ROW]
[ROW][C]Raw Input[/C][C]view raw input (R code) [/C][/ROW]
[ROW][C]Raw Output[/C][C]view raw output of R engine [/C][/ROW]
[ROW][C]Computing time[/C][C]2 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'Gwilym Jenkins' @ 72.249.127.135[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=33786&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=33786&T=0

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135







Univariate ARIMA Extrapolation Forecast
timeY[t]F[t]95% LB95% UBp-value(H0: Y[t] = F[t])P(F[t]>Y[t-1])P(F[t]>Y[t-s])P(F[t]>Y[85])
73122683-------
74115614-------
75116566-------
76111272-------
77104609-------
78101802-------
7994542-------
8093051-------
81124129-------
82130374-------
83123946-------
84114971-------
85105531-------
8610491999728.887194907.2664104550.50790.01740.009200.0092
8710478299741.267692934.541106547.99410.07330.06800.0477
8810128195080.564586748.9965103412.13250.07230.01121e-040.007
899454588988.169379370.554198605.78450.12870.00617e-044e-04
909324885707.240474956.332796458.14810.08460.05360.00172e-04
918403179312.23467536.602191087.86590.21610.01020.00560
928748678465.825965747.768191183.88380.08220.19550.01230
93115867110813.906297218.5953124409.21720.23320.99960.02750.7769
94120327118706.3285104287.0373133125.61980.41280.65020.05640.9633
95117008114340.642299141.9766129539.30780.36540.22010.10770.872
96108811105020.484589080.5062120960.46270.32060.07020.11060.475
9710451994831.904378183.5419111480.26670.1270.04990.10390.1039

\begin{tabular}{lllllllll}
\hline
Univariate ARIMA Extrapolation Forecast \tabularnewline
time & Y[t] & F[t] & 95% LB & 95% UB & p-value(H0: Y[t] = F[t]) & P(F[t]>Y[t-1]) & P(F[t]>Y[t-s]) & P(F[t]>Y[85]) \tabularnewline
73 & 122683 & - & - & - & - & - & - & - \tabularnewline
74 & 115614 & - & - & - & - & - & - & - \tabularnewline
75 & 116566 & - & - & - & - & - & - & - \tabularnewline
76 & 111272 & - & - & - & - & - & - & - \tabularnewline
77 & 104609 & - & - & - & - & - & - & - \tabularnewline
78 & 101802 & - & - & - & - & - & - & - \tabularnewline
79 & 94542 & - & - & - & - & - & - & - \tabularnewline
80 & 93051 & - & - & - & - & - & - & - \tabularnewline
81 & 124129 & - & - & - & - & - & - & - \tabularnewline
82 & 130374 & - & - & - & - & - & - & - \tabularnewline
83 & 123946 & - & - & - & - & - & - & - \tabularnewline
84 & 114971 & - & - & - & - & - & - & - \tabularnewline
85 & 105531 & - & - & - & - & - & - & - \tabularnewline
86 & 104919 & 99728.8871 & 94907.2664 & 104550.5079 & 0.0174 & 0.0092 & 0 & 0.0092 \tabularnewline
87 & 104782 & 99741.2676 & 92934.541 & 106547.9941 & 0.0733 & 0.068 & 0 & 0.0477 \tabularnewline
88 & 101281 & 95080.5645 & 86748.9965 & 103412.1325 & 0.0723 & 0.0112 & 1e-04 & 0.007 \tabularnewline
89 & 94545 & 88988.1693 & 79370.5541 & 98605.7845 & 0.1287 & 0.0061 & 7e-04 & 4e-04 \tabularnewline
90 & 93248 & 85707.2404 & 74956.3327 & 96458.1481 & 0.0846 & 0.0536 & 0.0017 & 2e-04 \tabularnewline
91 & 84031 & 79312.234 & 67536.6021 & 91087.8659 & 0.2161 & 0.0102 & 0.0056 & 0 \tabularnewline
92 & 87486 & 78465.8259 & 65747.7681 & 91183.8838 & 0.0822 & 0.1955 & 0.0123 & 0 \tabularnewline
93 & 115867 & 110813.9062 & 97218.5953 & 124409.2172 & 0.2332 & 0.9996 & 0.0275 & 0.7769 \tabularnewline
94 & 120327 & 118706.3285 & 104287.0373 & 133125.6198 & 0.4128 & 0.6502 & 0.0564 & 0.9633 \tabularnewline
95 & 117008 & 114340.6422 & 99141.9766 & 129539.3078 & 0.3654 & 0.2201 & 0.1077 & 0.872 \tabularnewline
96 & 108811 & 105020.4845 & 89080.5062 & 120960.4627 & 0.3206 & 0.0702 & 0.1106 & 0.475 \tabularnewline
97 & 104519 & 94831.9043 & 78183.5419 & 111480.2667 & 0.127 & 0.0499 & 0.1039 & 0.1039 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=33786&T=1

[TABLE]
[ROW][C]Univariate ARIMA Extrapolation Forecast[/C][/ROW]
[ROW][C]time[/C][C]Y[t][/C][C]F[t][/C][C]95% LB[/C][C]95% UB[/C][C]p-value(H0: Y[t] = F[t])[/C][C]P(F[t]>Y[t-1])[/C][C]P(F[t]>Y[t-s])[/C][C]P(F[t]>Y[85])[/C][/ROW]
[ROW][C]73[/C][C]122683[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]74[/C][C]115614[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]75[/C][C]116566[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]76[/C][C]111272[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]77[/C][C]104609[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]78[/C][C]101802[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]79[/C][C]94542[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]80[/C][C]93051[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]81[/C][C]124129[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]82[/C][C]130374[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]83[/C][C]123946[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]84[/C][C]114971[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]85[/C][C]105531[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][C]-[/C][/ROW]
[ROW][C]86[/C][C]104919[/C][C]99728.8871[/C][C]94907.2664[/C][C]104550.5079[/C][C]0.0174[/C][C]0.0092[/C][C]0[/C][C]0.0092[/C][/ROW]
[ROW][C]87[/C][C]104782[/C][C]99741.2676[/C][C]92934.541[/C][C]106547.9941[/C][C]0.0733[/C][C]0.068[/C][C]0[/C][C]0.0477[/C][/ROW]
[ROW][C]88[/C][C]101281[/C][C]95080.5645[/C][C]86748.9965[/C][C]103412.1325[/C][C]0.0723[/C][C]0.0112[/C][C]1e-04[/C][C]0.007[/C][/ROW]
[ROW][C]89[/C][C]94545[/C][C]88988.1693[/C][C]79370.5541[/C][C]98605.7845[/C][C]0.1287[/C][C]0.0061[/C][C]7e-04[/C][C]4e-04[/C][/ROW]
[ROW][C]90[/C][C]93248[/C][C]85707.2404[/C][C]74956.3327[/C][C]96458.1481[/C][C]0.0846[/C][C]0.0536[/C][C]0.0017[/C][C]2e-04[/C][/ROW]
[ROW][C]91[/C][C]84031[/C][C]79312.234[/C][C]67536.6021[/C][C]91087.8659[/C][C]0.2161[/C][C]0.0102[/C][C]0.0056[/C][C]0[/C][/ROW]
[ROW][C]92[/C][C]87486[/C][C]78465.8259[/C][C]65747.7681[/C][C]91183.8838[/C][C]0.0822[/C][C]0.1955[/C][C]0.0123[/C][C]0[/C][/ROW]
[ROW][C]93[/C][C]115867[/C][C]110813.9062[/C][C]97218.5953[/C][C]124409.2172[/C][C]0.2332[/C][C]0.9996[/C][C]0.0275[/C][C]0.7769[/C][/ROW]
[ROW][C]94[/C][C]120327[/C][C]118706.3285[/C][C]104287.0373[/C][C]133125.6198[/C][C]0.4128[/C][C]0.6502[/C][C]0.0564[/C][C]0.9633[/C][/ROW]
[ROW][C]95[/C][C]117008[/C][C]114340.6422[/C][C]99141.9766[/C][C]129539.3078[/C][C]0.3654[/C][C]0.2201[/C][C]0.1077[/C][C]0.872[/C][/ROW]
[ROW][C]96[/C][C]108811[/C][C]105020.4845[/C][C]89080.5062[/C][C]120960.4627[/C][C]0.3206[/C][C]0.0702[/C][C]0.1106[/C][C]0.475[/C][/ROW]
[ROW][C]97[/C][C]104519[/C][C]94831.9043[/C][C]78183.5419[/C][C]111480.2667[/C][C]0.127[/C][C]0.0499[/C][C]0.1039[/C][C]0.1039[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=33786&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=33786&T=1

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Univariate ARIMA Extrapolation Forecast
timeY[t]F[t]95% LB95% UBp-value(H0: Y[t] = F[t])P(F[t]>Y[t-1])P(F[t]>Y[t-s])P(F[t]>Y[85])
73122683-------
74115614-------
75116566-------
76111272-------
77104609-------
78101802-------
7994542-------
8093051-------
81124129-------
82130374-------
83123946-------
84114971-------
85105531-------
8610491999728.887194907.2664104550.50790.01740.009200.0092
8710478299741.267692934.541106547.99410.07330.06800.0477
8810128195080.564586748.9965103412.13250.07230.01121e-040.007
899454588988.169379370.554198605.78450.12870.00617e-044e-04
909324885707.240474956.332796458.14810.08460.05360.00172e-04
918403179312.23467536.602191087.86590.21610.01020.00560
928748678465.825965747.768191183.88380.08220.19550.01230
93115867110813.906297218.5953124409.21720.23320.99960.02750.7769
94120327118706.3285104287.0373133125.61980.41280.65020.05640.9633
95117008114340.642299141.9766129539.30780.36540.22010.10770.872
96108811105020.484589080.5062120960.46270.32060.07020.11060.475
9710451994831.904378183.5419111480.26670.1270.04990.10390.1039







Univariate ARIMA Extrapolation Forecast Performance
time% S.E.PEMAPESq.EMSERMSE
860.02470.0520.004326937271.52592244772.62721498.2565
870.03480.05050.004225408983.62892117415.30241455.1341
880.04470.06520.005438445400.19393203783.34951789.9115
890.05510.06240.005230878367.4242573197.28531604.1189
900.0640.0880.007356863055.6224738587.96852176.8298
910.07580.05950.00522266752.73451855562.72791362.1904
920.08270.1150.009681363540.19856780295.01652603.9
930.06260.04560.003825533756.70852127813.0591458.7025
940.0620.01370.00112626576.0778218881.3398467.8476
950.06780.02330.00197114797.4172592899.7848769.9999
960.07740.03610.00314368008.09381197334.00781094.2276
970.08960.10220.008593839823.73617819985.31132796.4237

\begin{tabular}{lllllllll}
\hline
Univariate ARIMA Extrapolation Forecast Performance \tabularnewline
time & % S.E. & PE & MAPE & Sq.E & MSE & RMSE \tabularnewline
86 & 0.0247 & 0.052 & 0.0043 & 26937271.5259 & 2244772.6272 & 1498.2565 \tabularnewline
87 & 0.0348 & 0.0505 & 0.0042 & 25408983.6289 & 2117415.3024 & 1455.1341 \tabularnewline
88 & 0.0447 & 0.0652 & 0.0054 & 38445400.1939 & 3203783.3495 & 1789.9115 \tabularnewline
89 & 0.0551 & 0.0624 & 0.0052 & 30878367.424 & 2573197.2853 & 1604.1189 \tabularnewline
90 & 0.064 & 0.088 & 0.0073 & 56863055.622 & 4738587.9685 & 2176.8298 \tabularnewline
91 & 0.0758 & 0.0595 & 0.005 & 22266752.7345 & 1855562.7279 & 1362.1904 \tabularnewline
92 & 0.0827 & 0.115 & 0.0096 & 81363540.1985 & 6780295.0165 & 2603.9 \tabularnewline
93 & 0.0626 & 0.0456 & 0.0038 & 25533756.7085 & 2127813.059 & 1458.7025 \tabularnewline
94 & 0.062 & 0.0137 & 0.0011 & 2626576.0778 & 218881.3398 & 467.8476 \tabularnewline
95 & 0.0678 & 0.0233 & 0.0019 & 7114797.4172 & 592899.7848 & 769.9999 \tabularnewline
96 & 0.0774 & 0.0361 & 0.003 & 14368008.0938 & 1197334.0078 & 1094.2276 \tabularnewline
97 & 0.0896 & 0.1022 & 0.0085 & 93839823.7361 & 7819985.3113 & 2796.4237 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=33786&T=2

[TABLE]
[ROW][C]Univariate ARIMA Extrapolation Forecast Performance[/C][/ROW]
[ROW][C]time[/C][C]% S.E.[/C][C]PE[/C][C]MAPE[/C][C]Sq.E[/C][C]MSE[/C][C]RMSE[/C][/ROW]
[ROW][C]86[/C][C]0.0247[/C][C]0.052[/C][C]0.0043[/C][C]26937271.5259[/C][C]2244772.6272[/C][C]1498.2565[/C][/ROW]
[ROW][C]87[/C][C]0.0348[/C][C]0.0505[/C][C]0.0042[/C][C]25408983.6289[/C][C]2117415.3024[/C][C]1455.1341[/C][/ROW]
[ROW][C]88[/C][C]0.0447[/C][C]0.0652[/C][C]0.0054[/C][C]38445400.1939[/C][C]3203783.3495[/C][C]1789.9115[/C][/ROW]
[ROW][C]89[/C][C]0.0551[/C][C]0.0624[/C][C]0.0052[/C][C]30878367.424[/C][C]2573197.2853[/C][C]1604.1189[/C][/ROW]
[ROW][C]90[/C][C]0.064[/C][C]0.088[/C][C]0.0073[/C][C]56863055.622[/C][C]4738587.9685[/C][C]2176.8298[/C][/ROW]
[ROW][C]91[/C][C]0.0758[/C][C]0.0595[/C][C]0.005[/C][C]22266752.7345[/C][C]1855562.7279[/C][C]1362.1904[/C][/ROW]
[ROW][C]92[/C][C]0.0827[/C][C]0.115[/C][C]0.0096[/C][C]81363540.1985[/C][C]6780295.0165[/C][C]2603.9[/C][/ROW]
[ROW][C]93[/C][C]0.0626[/C][C]0.0456[/C][C]0.0038[/C][C]25533756.7085[/C][C]2127813.059[/C][C]1458.7025[/C][/ROW]
[ROW][C]94[/C][C]0.062[/C][C]0.0137[/C][C]0.0011[/C][C]2626576.0778[/C][C]218881.3398[/C][C]467.8476[/C][/ROW]
[ROW][C]95[/C][C]0.0678[/C][C]0.0233[/C][C]0.0019[/C][C]7114797.4172[/C][C]592899.7848[/C][C]769.9999[/C][/ROW]
[ROW][C]96[/C][C]0.0774[/C][C]0.0361[/C][C]0.003[/C][C]14368008.0938[/C][C]1197334.0078[/C][C]1094.2276[/C][/ROW]
[ROW][C]97[/C][C]0.0896[/C][C]0.1022[/C][C]0.0085[/C][C]93839823.7361[/C][C]7819985.3113[/C][C]2796.4237[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=33786&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=33786&T=2

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Univariate ARIMA Extrapolation Forecast Performance
time% S.E.PEMAPESq.EMSERMSE
860.02470.0520.004326937271.52592244772.62721498.2565
870.03480.05050.004225408983.62892117415.30241455.1341
880.04470.06520.005438445400.19393203783.34951789.9115
890.05510.06240.005230878367.4242573197.28531604.1189
900.0640.0880.007356863055.6224738587.96852176.8298
910.07580.05950.00522266752.73451855562.72791362.1904
920.08270.1150.009681363540.19856780295.01652603.9
930.06260.04560.003825533756.70852127813.0591458.7025
940.0620.01370.00112626576.0778218881.3398467.8476
950.06780.02330.00197114797.4172592899.7848769.9999
960.07740.03610.00314368008.09381197334.00781094.2276
970.08960.10220.008593839823.73617819985.31132796.4237



Parameters (Session):
par1 = 12 ; par2 = 1 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 0 ; par7 = 1 ; par8 = 2 ; par9 = 1 ; par10 = FALSE ;
Parameters (R input):
par1 = 12 ; par2 = 1 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 0 ; par7 = 1 ; par8 = 2 ; par9 = 1 ; par10 = FALSE ;
R code (references can be found in the software module):
par1 <- as.numeric(par1) #cut off periods
par2 <- as.numeric(par2) #lambda
par3 <- as.numeric(par3) #degree of non-seasonal differencing
par4 <- as.numeric(par4) #degree of seasonal differencing
par5 <- as.numeric(par5) #seasonal period
par6 <- as.numeric(par6) #p
par7 <- as.numeric(par7) #q
par8 <- as.numeric(par8) #P
par9 <- as.numeric(par9) #Q
if (par10 == 'TRUE') par10 <- TRUE
if (par10 == 'FALSE') par10 <- FALSE
if (par2 == 0) x <- log(x)
if (par2 != 0) x <- x^par2
lx <- length(x)
first <- lx - 2*par1
nx <- lx - par1
nx1 <- nx + 1
fx <- lx - nx
if (fx < 1) {
fx <- par5
nx1 <- lx + fx - 1
first <- lx - 2*fx
}
first <- 1
if (fx < 3) fx <- round(lx/10,0)
(arima.out <- arima(x[1:nx], order=c(par6,par3,par7), seasonal=list(order=c(par8,par4,par9), period=par5), include.mean=par10, method='ML'))
(forecast <- predict(arima.out,fx))
(lb <- forecast$pred - 1.96 * forecast$se)
(ub <- forecast$pred + 1.96 * forecast$se)
if (par2 == 0) {
x <- exp(x)
forecast$pred <- exp(forecast$pred)
lb <- exp(lb)
ub <- exp(ub)
}
if (par2 != 0) {
x <- x^(1/par2)
forecast$pred <- forecast$pred^(1/par2)
lb <- lb^(1/par2)
ub <- ub^(1/par2)
}
if (par2 < 0) {
olb <- lb
lb <- ub
ub <- olb
}
(actandfor <- c(x[1:nx], forecast$pred))
(perc.se <- (ub-forecast$pred)/1.96/forecast$pred)
bitmap(file='test1.png')
opar <- par(mar=c(4,4,2,2),las=1)
ylim <- c( min(x[first:nx],lb), max(x[first:nx],ub))
plot(x,ylim=ylim,type='n',xlim=c(first,lx))
usr <- par('usr')
rect(usr[1],usr[3],nx+1,usr[4],border=NA,col='lemonchiffon')
rect(nx1,usr[3],usr[2],usr[4],border=NA,col='lavender')
abline(h= (-3:3)*2 , col ='gray', lty =3)
polygon( c(nx1:lx,lx:nx1), c(lb,rev(ub)), col = 'orange', lty=2,border=NA)
lines(nx1:lx, lb , lty=2)
lines(nx1:lx, ub , lty=2)
lines(x, lwd=2)
lines(nx1:lx, forecast$pred , lwd=2 , col ='white')
box()
par(opar)
dev.off()
prob.dec <- array(NA, dim=fx)
prob.sdec <- array(NA, dim=fx)
prob.ldec <- array(NA, dim=fx)
prob.pval <- array(NA, dim=fx)
perf.pe <- array(0, dim=fx)
perf.mape <- array(0, dim=fx)
perf.se <- array(0, dim=fx)
perf.mse <- array(0, dim=fx)
perf.rmse <- array(0, dim=fx)
for (i in 1:fx) {
locSD <- (ub[i] - forecast$pred[i]) / 1.96
perf.pe[i] = (x[nx+i] - forecast$pred[i]) / forecast$pred[i]
perf.mape[i] = perf.mape[i] + abs(perf.pe[i])
perf.se[i] = (x[nx+i] - forecast$pred[i])^2
perf.mse[i] = perf.mse[i] + perf.se[i]
prob.dec[i] = pnorm((x[nx+i-1] - forecast$pred[i]) / locSD)
prob.sdec[i] = pnorm((x[nx+i-par5] - forecast$pred[i]) / locSD)
prob.ldec[i] = pnorm((x[nx] - forecast$pred[i]) / locSD)
prob.pval[i] = pnorm(abs(x[nx+i] - forecast$pred[i]) / locSD)
}
perf.mape = perf.mape / fx
perf.mse = perf.mse / fx
perf.rmse = sqrt(perf.mse)
bitmap(file='test2.png')
plot(forecast$pred, pch=19, type='b',main='ARIMA Extrapolation Forecast', ylab='Forecast and 95% CI', xlab='time',ylim=c(min(lb),max(ub)))
dum <- forecast$pred
dum[1:12] <- x[(nx+1):lx]
lines(dum, lty=1)
lines(ub,lty=3)
lines(lb,lty=3)
dev.off()
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Univariate ARIMA Extrapolation Forecast',9,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'time',1,header=TRUE)
a<-table.element(a,'Y[t]',1,header=TRUE)
a<-table.element(a,'F[t]',1,header=TRUE)
a<-table.element(a,'95% LB',1,header=TRUE)
a<-table.element(a,'95% UB',1,header=TRUE)
a<-table.element(a,'p-value
(H0: Y[t] = F[t])',1,header=TRUE)
a<-table.element(a,'P(F[t]>Y[t-1])',1,header=TRUE)
a<-table.element(a,'P(F[t]>Y[t-s])',1,header=TRUE)
mylab <- paste('P(F[t]>Y[',nx,sep='')
mylab <- paste(mylab,'])',sep='')
a<-table.element(a,mylab,1,header=TRUE)
a<-table.row.end(a)
for (i in (nx-par5):nx) {
a<-table.row.start(a)
a<-table.element(a,i,header=TRUE)
a<-table.element(a,x[i])
a<-table.element(a,'-')
a<-table.element(a,'-')
a<-table.element(a,'-')
a<-table.element(a,'-')
a<-table.element(a,'-')
a<-table.element(a,'-')
a<-table.element(a,'-')
a<-table.row.end(a)
}
for (i in 1:fx) {
a<-table.row.start(a)
a<-table.element(a,nx+i,header=TRUE)
a<-table.element(a,round(x[nx+i],4))
a<-table.element(a,round(forecast$pred[i],4))
a<-table.element(a,round(lb[i],4))
a<-table.element(a,round(ub[i],4))
a<-table.element(a,round((1-prob.pval[i]),4))
a<-table.element(a,round((1-prob.dec[i]),4))
a<-table.element(a,round((1-prob.sdec[i]),4))
a<-table.element(a,round((1-prob.ldec[i]),4))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Univariate ARIMA Extrapolation Forecast Performance',7,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'time',1,header=TRUE)
a<-table.element(a,'% S.E.',1,header=TRUE)
a<-table.element(a,'PE',1,header=TRUE)
a<-table.element(a,'MAPE',1,header=TRUE)
a<-table.element(a,'Sq.E',1,header=TRUE)
a<-table.element(a,'MSE',1,header=TRUE)
a<-table.element(a,'RMSE',1,header=TRUE)
a<-table.row.end(a)
for (i in 1:fx) {
a<-table.row.start(a)
a<-table.element(a,nx+i,header=TRUE)
a<-table.element(a,round(perc.se[i],4))
a<-table.element(a,round(perf.pe[i],4))
a<-table.element(a,round(perf.mape[i],4))
a<-table.element(a,round(perf.se[i],4))
a<-table.element(a,round(perf.mse[i],4))
a<-table.element(a,round(perf.rmse[i],4))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable1.tab')