Free Statistics

of Irreproducible Research!

Author's title

Author*The author of this computation has been verified*
R Software Modulerwasp_arimabackwardselection.wasp
Title produced by softwareARIMA Backward Selection
Date of computationMon, 08 Dec 2008 13:09:39 -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/08/t1228767091cryaty04u8hvdfx.htm/, Retrieved Thu, 16 May 2024 21:45:35 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=30918, Retrieved Thu, 16 May 2024 21:45:35 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact164
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-     [Univariate Data Series] [data set] [2008-12-01 19:54:57] [b98453cac15ba1066b407e146608df68]
F RMPD  [Standard Deviation-Mean Plot] [step 1] [2008-12-08 19:31:21] [5161246d1ccc1b670cc664d03050f084]
F RM D    [Variance Reduction Matrix] [step 2] [2008-12-08 19:34:58] [5161246d1ccc1b670cc664d03050f084]
F RMP       [Spectral Analysis] [step 2] [2008-12-08 19:40:15] [5161246d1ccc1b670cc664d03050f084]
- RMP         [(Partial) Autocorrelation Function] [step 2] [2008-12-08 19:45:51] [5161246d1ccc1b670cc664d03050f084]
F   P           [(Partial) Autocorrelation Function] [step3] [2008-12-08 19:51:58] [5161246d1ccc1b670cc664d03050f084]
F RMPD              [ARIMA Backward Selection] [] [2008-12-08 20:09:39] [e515c0250d6233b5d2604259ab52cebe] [Current]
-   PD                [ARIMA Backward Selection] [verbetering stap 5] [2008-12-15 16:48:15] [e43247bc0ab243a5af99ac7f55ba0b41]
Feedback Forum
2008-12-10 15:48:20 [Ken Van den Heuvel] [reply
Verkeerd gebruikt van de module en verkeerde parameters.

Pas je lambda aan naar 1 zoals vermeld in vorige feedback.

Hier heb je een blog van een voor jouw verbeterde computatie.

http://www.freestatistics.org/blog/index.php?v=date/2008/Dec/10/t12289239121k4bcqdsv33igoo.htm/

Ik meld even dat ik AR op 2 heb gezet omdat je anders een overparameterisatie krijgt in de module en geen resultaat te zien krijgt (foutmelding).

Uit deze verbetering kan ja dan ook afleiden dat mijn analyse uit de verberting van je voorgaande vraag correct is. We hebben inderdaad een AR2 proces in combinatie met een SMA1.
2008-12-14 15:09:09 [Chi-Kwong Man] [reply
Parameter is verkeerd, vandaar de verkeerde resultaat
2008-12-15 12:57:44 [Kristof Augustyns] [reply
Verkeerde parameter en dus foute berekening en conclusie.
Lambda veranderen naar 1.
2008-12-15 17:12:10 [Lindsay Heyndrickx] [reply
Hier moet je de lamda waarde weer aanpassen naar 1 en de parameters zoveel mogelijk maximaliseren om meerdere modellen te krijgen zodat we kunnen aflezen wat voor een proces het juist is. http://www.freestatistics.org/blog/date/2008/Dec/15/t12293597446u6o1vktxm9qu0w.htm , als we naar de gegevens in deze berekening kijken hebben we hier te maken met een ar2 en een sma1 proces.

Post a new message
Dataseries X:
83,1
89,6
105,7
110,7
110,4
109
106
100,9
114,3
101,2
109,2
111,6
91,7
93,7
105,7
109,5
105,3
102,8
100,6
97,6
110,3
107,2
107,2
108,1
97,1
92,2
112,2
111,6
115,7
111,3
104,2
103,2
112,7
106,4
102,6
110,6
95,2
89
112,5
116,8
107,2
113,6
101,8
102,6
122,7
110,3
110,5
121,6
100,3
100,7
123,4
127,1
124,1
131,2
111,6
114,2
130,1
125,9
119
133,8
107,5
113,5
134,4
126,8
135,6
139,9
129,8
131
153,1
134,1
144,1
155,9
123,3
128,1
144,3
153
149,9
150,9
141
138,9
157,4
142,9
151,7
161
138,5
135,9
151,5
164
159,1
157
142,1
144,8
152,1
154,6
148,7
157,7
146,7




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time6 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 & 6 seconds \tabularnewline
R Server & 'Gwilym Jenkins' @ 72.249.127.135 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=30918&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]6 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=30918&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=30918&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 time6 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135







ARIMA Parameter Estimation and Backward Selection
Iterationma1sma1
Estimates ( 1 )-0.6212-0.997
(p-val)(0 )(0.069 )
Estimates ( 2 )-0.60960
(p-val)(0 )(NA )
Estimates ( 3 )NANA
(p-val)(NA )(NA )

\begin{tabular}{lllllllll}
\hline
ARIMA Parameter Estimation and Backward Selection \tabularnewline
Iteration & ma1 & sma1 \tabularnewline
Estimates ( 1 ) & -0.6212 & -0.997 \tabularnewline
(p-val) & (0 ) & (0.069 ) \tabularnewline
Estimates ( 2 ) & -0.6096 & 0 \tabularnewline
(p-val) & (0 ) & (NA ) \tabularnewline
Estimates ( 3 ) & NA & NA \tabularnewline
(p-val) & (NA ) & (NA ) \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=30918&T=1

[TABLE]
[ROW][C]ARIMA Parameter Estimation and Backward Selection[/C][/ROW]
[ROW][C]Iteration[/C][C]ma1[/C][C]sma1[/C][/ROW]
[ROW][C]Estimates ( 1 )[/C][C]-0.6212[/C][C]-0.997[/C][/ROW]
[ROW][C](p-val)[/C][C](0 )[/C][C](0.069 )[/C][/ROW]
[ROW][C]Estimates ( 2 )[/C][C]-0.6096[/C][C]0[/C][/ROW]
[ROW][C](p-val)[/C][C](0 )[/C][C](NA )[/C][/ROW]
[ROW][C]Estimates ( 3 )[/C][C]NA[/C][C]NA[/C][/ROW]
[ROW][C](p-val)[/C][C](NA )[/C][C](NA )[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=30918&T=1

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

As an alternative you can also use a QR Code:  

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

ARIMA Parameter Estimation and Backward Selection
Iterationma1sma1
Estimates ( 1 )-0.6212-0.997
(p-val)(0 )(0.069 )
Estimates ( 2 )-0.60960
(p-val)(0 )(NA )
Estimates ( 3 )NANA
(p-val)(NA )(NA )







Estimated ARIMA Residuals
Value
-0.00551254248596577
-0.00505012739401979
-0.00726305774750156
-0.00542249417534895
-0.00737010645677864
-0.00579415486116998
-0.00286503242690045
0.000378702367761087
-8.17345440624904e-05
0.0104825414251933
-0.00207228825342951
-0.00280741975971735
0.0120501439408313
-0.0058664237583692
0.00343227056040192
-0.00390254105612069
0.00504352970351028
0.000435992090996791
-0.00510921363055705
0.000737796289292654
-0.0041374010384195
-0.000285644154744681
-0.00986699417468917
0.00169371412398637
0.00425023007601252
-0.00854122948141439
0.00487152921345858
0.00471167975945009
-0.00873927749325315
0.00611758453412766
-0.00606257185060688
0.00140843289415810
0.0103055193431368
0.00112821589939743
-0.00087817569991895
0.00795354824077616
0.00137793455998619
0.00219180889190540
0.00509077962140586
0.00336563592761602
0.00189489920634594
0.00989626691762395
-0.00922141548278538
0.000475566681805477
0.000783295457086744
0.00698232142150743
-0.00531072770439916
0.00652613404862815
-0.00289634301685922
0.00668075032653693
0.00242640800759584
-0.0113509617969235
0.00632480801573813
0.00745831077081098
0.00479371989032884
0.00603427391612683
0.00826989111155604
-0.00458806009175029
0.00837602193979557
0.00771582776566663
-0.0038466809364385
0.00247879460084039
-0.00721416381239448
0.00238698808266661
-0.000482422025920787
-0.00103415941468876
0.000483507470202114
-0.000785446876482055
-0.00127955516049760
-0.00361866181168854
0.00544500840461702
0.0026049664086716
0.0069315899524818
-0.000221361272825690
-0.00921804561828906
0.00349787954693614
-0.00108605999642489
-0.00440396238417689
-0.00670879828800049
9.36307847013925e-05
-0.0123356439786673
0.00736061973452239
-0.00401072694629286
-0.00329748109664989
0.0147348386589905

\begin{tabular}{lllllllll}
\hline
Estimated ARIMA Residuals \tabularnewline
Value \tabularnewline
-0.00551254248596577 \tabularnewline
-0.00505012739401979 \tabularnewline
-0.00726305774750156 \tabularnewline
-0.00542249417534895 \tabularnewline
-0.00737010645677864 \tabularnewline
-0.00579415486116998 \tabularnewline
-0.00286503242690045 \tabularnewline
0.000378702367761087 \tabularnewline
-8.17345440624904e-05 \tabularnewline
0.0104825414251933 \tabularnewline
-0.00207228825342951 \tabularnewline
-0.00280741975971735 \tabularnewline
0.0120501439408313 \tabularnewline
-0.0058664237583692 \tabularnewline
0.00343227056040192 \tabularnewline
-0.00390254105612069 \tabularnewline
0.00504352970351028 \tabularnewline
0.000435992090996791 \tabularnewline
-0.00510921363055705 \tabularnewline
0.000737796289292654 \tabularnewline
-0.0041374010384195 \tabularnewline
-0.000285644154744681 \tabularnewline
-0.00986699417468917 \tabularnewline
0.00169371412398637 \tabularnewline
0.00425023007601252 \tabularnewline
-0.00854122948141439 \tabularnewline
0.00487152921345858 \tabularnewline
0.00471167975945009 \tabularnewline
-0.00873927749325315 \tabularnewline
0.00611758453412766 \tabularnewline
-0.00606257185060688 \tabularnewline
0.00140843289415810 \tabularnewline
0.0103055193431368 \tabularnewline
0.00112821589939743 \tabularnewline
-0.00087817569991895 \tabularnewline
0.00795354824077616 \tabularnewline
0.00137793455998619 \tabularnewline
0.00219180889190540 \tabularnewline
0.00509077962140586 \tabularnewline
0.00336563592761602 \tabularnewline
0.00189489920634594 \tabularnewline
0.00989626691762395 \tabularnewline
-0.00922141548278538 \tabularnewline
0.000475566681805477 \tabularnewline
0.000783295457086744 \tabularnewline
0.00698232142150743 \tabularnewline
-0.00531072770439916 \tabularnewline
0.00652613404862815 \tabularnewline
-0.00289634301685922 \tabularnewline
0.00668075032653693 \tabularnewline
0.00242640800759584 \tabularnewline
-0.0113509617969235 \tabularnewline
0.00632480801573813 \tabularnewline
0.00745831077081098 \tabularnewline
0.00479371989032884 \tabularnewline
0.00603427391612683 \tabularnewline
0.00826989111155604 \tabularnewline
-0.00458806009175029 \tabularnewline
0.00837602193979557 \tabularnewline
0.00771582776566663 \tabularnewline
-0.0038466809364385 \tabularnewline
0.00247879460084039 \tabularnewline
-0.00721416381239448 \tabularnewline
0.00238698808266661 \tabularnewline
-0.000482422025920787 \tabularnewline
-0.00103415941468876 \tabularnewline
0.000483507470202114 \tabularnewline
-0.000785446876482055 \tabularnewline
-0.00127955516049760 \tabularnewline
-0.00361866181168854 \tabularnewline
0.00544500840461702 \tabularnewline
0.0026049664086716 \tabularnewline
0.0069315899524818 \tabularnewline
-0.000221361272825690 \tabularnewline
-0.00921804561828906 \tabularnewline
0.00349787954693614 \tabularnewline
-0.00108605999642489 \tabularnewline
-0.00440396238417689 \tabularnewline
-0.00670879828800049 \tabularnewline
9.36307847013925e-05 \tabularnewline
-0.0123356439786673 \tabularnewline
0.00736061973452239 \tabularnewline
-0.00401072694629286 \tabularnewline
-0.00329748109664989 \tabularnewline
0.0147348386589905 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=30918&T=2

[TABLE]
[ROW][C]Estimated ARIMA Residuals[/C][/ROW]
[ROW][C]Value[/C][/ROW]
[ROW][C]-0.00551254248596577[/C][/ROW]
[ROW][C]-0.00505012739401979[/C][/ROW]
[ROW][C]-0.00726305774750156[/C][/ROW]
[ROW][C]-0.00542249417534895[/C][/ROW]
[ROW][C]-0.00737010645677864[/C][/ROW]
[ROW][C]-0.00579415486116998[/C][/ROW]
[ROW][C]-0.00286503242690045[/C][/ROW]
[ROW][C]0.000378702367761087[/C][/ROW]
[ROW][C]-8.17345440624904e-05[/C][/ROW]
[ROW][C]0.0104825414251933[/C][/ROW]
[ROW][C]-0.00207228825342951[/C][/ROW]
[ROW][C]-0.00280741975971735[/C][/ROW]
[ROW][C]0.0120501439408313[/C][/ROW]
[ROW][C]-0.0058664237583692[/C][/ROW]
[ROW][C]0.00343227056040192[/C][/ROW]
[ROW][C]-0.00390254105612069[/C][/ROW]
[ROW][C]0.00504352970351028[/C][/ROW]
[ROW][C]0.000435992090996791[/C][/ROW]
[ROW][C]-0.00510921363055705[/C][/ROW]
[ROW][C]0.000737796289292654[/C][/ROW]
[ROW][C]-0.0041374010384195[/C][/ROW]
[ROW][C]-0.000285644154744681[/C][/ROW]
[ROW][C]-0.00986699417468917[/C][/ROW]
[ROW][C]0.00169371412398637[/C][/ROW]
[ROW][C]0.00425023007601252[/C][/ROW]
[ROW][C]-0.00854122948141439[/C][/ROW]
[ROW][C]0.00487152921345858[/C][/ROW]
[ROW][C]0.00471167975945009[/C][/ROW]
[ROW][C]-0.00873927749325315[/C][/ROW]
[ROW][C]0.00611758453412766[/C][/ROW]
[ROW][C]-0.00606257185060688[/C][/ROW]
[ROW][C]0.00140843289415810[/C][/ROW]
[ROW][C]0.0103055193431368[/C][/ROW]
[ROW][C]0.00112821589939743[/C][/ROW]
[ROW][C]-0.00087817569991895[/C][/ROW]
[ROW][C]0.00795354824077616[/C][/ROW]
[ROW][C]0.00137793455998619[/C][/ROW]
[ROW][C]0.00219180889190540[/C][/ROW]
[ROW][C]0.00509077962140586[/C][/ROW]
[ROW][C]0.00336563592761602[/C][/ROW]
[ROW][C]0.00189489920634594[/C][/ROW]
[ROW][C]0.00989626691762395[/C][/ROW]
[ROW][C]-0.00922141548278538[/C][/ROW]
[ROW][C]0.000475566681805477[/C][/ROW]
[ROW][C]0.000783295457086744[/C][/ROW]
[ROW][C]0.00698232142150743[/C][/ROW]
[ROW][C]-0.00531072770439916[/C][/ROW]
[ROW][C]0.00652613404862815[/C][/ROW]
[ROW][C]-0.00289634301685922[/C][/ROW]
[ROW][C]0.00668075032653693[/C][/ROW]
[ROW][C]0.00242640800759584[/C][/ROW]
[ROW][C]-0.0113509617969235[/C][/ROW]
[ROW][C]0.00632480801573813[/C][/ROW]
[ROW][C]0.00745831077081098[/C][/ROW]
[ROW][C]0.00479371989032884[/C][/ROW]
[ROW][C]0.00603427391612683[/C][/ROW]
[ROW][C]0.00826989111155604[/C][/ROW]
[ROW][C]-0.00458806009175029[/C][/ROW]
[ROW][C]0.00837602193979557[/C][/ROW]
[ROW][C]0.00771582776566663[/C][/ROW]
[ROW][C]-0.0038466809364385[/C][/ROW]
[ROW][C]0.00247879460084039[/C][/ROW]
[ROW][C]-0.00721416381239448[/C][/ROW]
[ROW][C]0.00238698808266661[/C][/ROW]
[ROW][C]-0.000482422025920787[/C][/ROW]
[ROW][C]-0.00103415941468876[/C][/ROW]
[ROW][C]0.000483507470202114[/C][/ROW]
[ROW][C]-0.000785446876482055[/C][/ROW]
[ROW][C]-0.00127955516049760[/C][/ROW]
[ROW][C]-0.00361866181168854[/C][/ROW]
[ROW][C]0.00544500840461702[/C][/ROW]
[ROW][C]0.0026049664086716[/C][/ROW]
[ROW][C]0.0069315899524818[/C][/ROW]
[ROW][C]-0.000221361272825690[/C][/ROW]
[ROW][C]-0.00921804561828906[/C][/ROW]
[ROW][C]0.00349787954693614[/C][/ROW]
[ROW][C]-0.00108605999642489[/C][/ROW]
[ROW][C]-0.00440396238417689[/C][/ROW]
[ROW][C]-0.00670879828800049[/C][/ROW]
[ROW][C]9.36307847013925e-05[/C][/ROW]
[ROW][C]-0.0123356439786673[/C][/ROW]
[ROW][C]0.00736061973452239[/C][/ROW]
[ROW][C]-0.00401072694629286[/C][/ROW]
[ROW][C]-0.00329748109664989[/C][/ROW]
[ROW][C]0.0147348386589905[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=30918&T=2

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

As an alternative you can also use a QR Code:  

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

Estimated ARIMA Residuals
Value
-0.00551254248596577
-0.00505012739401979
-0.00726305774750156
-0.00542249417534895
-0.00737010645677864
-0.00579415486116998
-0.00286503242690045
0.000378702367761087
-8.17345440624904e-05
0.0104825414251933
-0.00207228825342951
-0.00280741975971735
0.0120501439408313
-0.0058664237583692
0.00343227056040192
-0.00390254105612069
0.00504352970351028
0.000435992090996791
-0.00510921363055705
0.000737796289292654
-0.0041374010384195
-0.000285644154744681
-0.00986699417468917
0.00169371412398637
0.00425023007601252
-0.00854122948141439
0.00487152921345858
0.00471167975945009
-0.00873927749325315
0.00611758453412766
-0.00606257185060688
0.00140843289415810
0.0103055193431368
0.00112821589939743
-0.00087817569991895
0.00795354824077616
0.00137793455998619
0.00219180889190540
0.00509077962140586
0.00336563592761602
0.00189489920634594
0.00989626691762395
-0.00922141548278538
0.000475566681805477
0.000783295457086744
0.00698232142150743
-0.00531072770439916
0.00652613404862815
-0.00289634301685922
0.00668075032653693
0.00242640800759584
-0.0113509617969235
0.00632480801573813
0.00745831077081098
0.00479371989032884
0.00603427391612683
0.00826989111155604
-0.00458806009175029
0.00837602193979557
0.00771582776566663
-0.0038466809364385
0.00247879460084039
-0.00721416381239448
0.00238698808266661
-0.000482422025920787
-0.00103415941468876
0.000483507470202114
-0.000785446876482055
-0.00127955516049760
-0.00361866181168854
0.00544500840461702
0.0026049664086716
0.0069315899524818
-0.000221361272825690
-0.00921804561828906
0.00349787954693614
-0.00108605999642489
-0.00440396238417689
-0.00670879828800049
9.36307847013925e-05
-0.0123356439786673
0.00736061973452239
-0.00401072694629286
-0.00329748109664989
0.0147348386589905



Parameters (Session):
par1 = FALSE ; par2 = 0.1 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 0 ; par7 = 1 ; par8 = 0 ; par9 = 1 ;
Parameters (R input):
par1 = FALSE ; par2 = 0.1 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 0 ; par7 = 1 ; par8 = 0 ; par9 = 1 ;
R code (references can be found in the software module):
library(lattice)
if (par1 == 'TRUE') par1 <- TRUE
if (par1 == 'FALSE') par1 <- FALSE
par2 <- as.numeric(par2) #Box-Cox lambda transformation parameter
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) #degree (p) of the non-seasonal AR(p) polynomial
par7 <- as.numeric(par7) #degree (q) of the non-seasonal MA(q) polynomial
par8 <- as.numeric(par8) #degree (P) of the seasonal AR(P) polynomial
par9 <- as.numeric(par9) #degree (Q) of the seasonal MA(Q) polynomial
armaGR <- function(arima.out, names, n){
try1 <- arima.out$coef
try2 <- sqrt(diag(arima.out$var.coef))
try.data.frame <- data.frame(matrix(NA,ncol=4,nrow=length(names)))
dimnames(try.data.frame) <- list(names,c('coef','std','tstat','pv'))
try.data.frame[,1] <- try1
for(i in 1:length(try2)) try.data.frame[which(rownames(try.data.frame)==names(try2)[i]),2] <- try2[i]
try.data.frame[,3] <- try.data.frame[,1] / try.data.frame[,2]
try.data.frame[,4] <- round((1-pt(abs(try.data.frame[,3]),df=n-(length(try2)+1)))*2,5)
vector <- rep(NA,length(names))
vector[is.na(try.data.frame[,4])] <- 0
maxi <- which.max(try.data.frame[,4])
continue <- max(try.data.frame[,4],na.rm=TRUE) > .05
vector[maxi] <- 0
list(summary=try.data.frame,next.vector=vector,continue=continue)
}
arimaSelect <- function(series, order=c(13,0,0), seasonal=list(order=c(2,0,0),period=12), include.mean=F){
nrc <- order[1]+order[3]+seasonal$order[1]+seasonal$order[3]
coeff <- matrix(NA, nrow=nrc*2, ncol=nrc)
pval <- matrix(NA, nrow=nrc*2, ncol=nrc)
mylist <- rep(list(NULL), nrc)
names <- NULL
if(order[1] > 0) names <- paste('ar',1:order[1],sep='')
if(order[3] > 0) names <- c( names , paste('ma',1:order[3],sep='') )
if(seasonal$order[1] > 0) names <- c(names, paste('sar',1:seasonal$order[1],sep=''))
if(seasonal$order[3] > 0) names <- c(names, paste('sma',1:seasonal$order[3],sep=''))
arima.out <- arima(series, order=order, seasonal=seasonal, include.mean=include.mean, method='ML')
mylist[[1]] <- arima.out
last.arma <- armaGR(arima.out, names, length(series))
mystop <- FALSE
i <- 1
coeff[i,] <- last.arma[[1]][,1]
pval [i,] <- last.arma[[1]][,4]
i <- 2
aic <- arima.out$aic
while(!mystop){
mylist[[i]] <- arima.out
arima.out <- arima(series, order=order, seasonal=seasonal, include.mean=include.mean, method='ML', fixed=last.arma$next.vector)
aic <- c(aic, arima.out$aic)
last.arma <- armaGR(arima.out, names, length(series))
mystop <- !last.arma$continue
coeff[i,] <- last.arma[[1]][,1]
pval [i,] <- last.arma[[1]][,4]
i <- i+1
}
list(coeff, pval, mylist, aic=aic)
}
arimaSelectplot <- function(arimaSelect.out,noms,choix){
noms <- names(arimaSelect.out[[3]][[1]]$coef)
coeff <- arimaSelect.out[[1]]
k <- min(which(is.na(coeff[,1])))-1
coeff <- coeff[1:k,]
pval <- arimaSelect.out[[2]][1:k,]
aic <- arimaSelect.out$aic[1:k]
coeff[coeff==0] <- NA
n <- ncol(coeff)
if(missing(choix)) choix <- k
layout(matrix(c(1,1,1,2,
3,3,3,2,
3,3,3,4,
5,6,7,7),nr=4),
widths=c(10,35,45,15),
heights=c(30,30,15,15))
couleurs <- rainbow(75)[1:50]#(50)
ticks <- pretty(coeff)
par(mar=c(1,1,3,1))
plot(aic,k:1-.5,type='o',pch=21,bg='blue',cex=2,axes=F,lty=2,xpd=NA)
points(aic[choix],k-choix+.5,pch=21,cex=4,bg=2,xpd=NA)
title('aic',line=2)
par(mar=c(3,0,0,0))
plot(0,axes=F,xlab='',ylab='',xlim=range(ticks),ylim=c(.1,1))
rect(xleft = min(ticks) + (0:49)/50*(max(ticks)-min(ticks)),
xright = min(ticks) + (1:50)/50*(max(ticks)-min(ticks)),
ytop = rep(1,50),
ybottom= rep(0,50),col=couleurs,border=NA)
axis(1,ticks)
rect(xleft=min(ticks),xright=max(ticks),ytop=1,ybottom=0)
text(mean(coeff,na.rm=T),.5,'coefficients',cex=2,font=2)
par(mar=c(1,1,3,1))
image(1:n,1:k,t(coeff[k:1,]),axes=F,col=couleurs,zlim=range(ticks))
for(i in 1:n) for(j in 1:k) if(!is.na(coeff[j,i])) {
if(pval[j,i]<.01) symb = 'green'
else if( (pval[j,i]<.05) & (pval[j,i]>=.01)) symb = 'orange'
else if( (pval[j,i]<.1) & (pval[j,i]>=.05)) symb = 'red'
else symb = 'black'
polygon(c(i+.5 ,i+.2 ,i+.5 ,i+.5),
c(k-j+0.5,k-j+0.5,k-j+0.8,k-j+0.5),
col=symb)
if(j==choix) {
rect(xleft=i-.5,
xright=i+.5,
ybottom=k-j+1.5,
ytop=k-j+.5,
lwd=4)
text(i,
k-j+1,
round(coeff[j,i],2),
cex=1.2,
font=2)
}
else{
rect(xleft=i-.5,xright=i+.5,ybottom=k-j+1.5,ytop=k-j+.5)
text(i,k-j+1,round(coeff[j,i],2),cex=1.2,font=1)
}
}
axis(3,1:n,noms)
par(mar=c(0.5,0,0,0.5))
plot(0,axes=F,xlab='',ylab='',type='n',xlim=c(0,8),ylim=c(-.2,.8))
cols <- c('green','orange','red','black')
niv <- c('0','0.01','0.05','0.1')
for(i in 0:3){
polygon(c(1+2*i ,1+2*i ,1+2*i-.5 ,1+2*i),
c(.4 ,.7 , .4 , .4),
col=cols[i+1])
text(2*i,0.5,niv[i+1],cex=1.5)
}
text(8,.5,1,cex=1.5)
text(4,0,'p-value',cex=2)
box()
residus <- arimaSelect.out[[3]][[choix]]$res
par(mar=c(1,2,4,1))
acf(residus,main='')
title('acf',line=.5)
par(mar=c(1,2,4,1))
pacf(residus,main='')
title('pacf',line=.5)
par(mar=c(2,2,4,1))
qqnorm(residus,main='')
title('qq-norm',line=.5)
qqline(residus)
residus
}
if (par2 == 0) x <- log(x)
if (par2 != 0) x <- x^par2
(selection <- arimaSelect(x, order=c(par6,par3,par7), seasonal=list(order=c(par8,par4,par9), period=par5)))
bitmap(file='test1.png')
resid <- arimaSelectplot(selection)
dev.off()
resid
bitmap(file='test2.png')
acf(resid,length(resid)/2, main='Residual Autocorrelation Function')
dev.off()
bitmap(file='test3.png')
pacf(resid,length(resid)/2, main='Residual Partial Autocorrelation Function')
dev.off()
bitmap(file='test4.png')
cpgram(resid, main='Residual Cumulative Periodogram')
dev.off()
bitmap(file='test5.png')
hist(resid, main='Residual Histogram', xlab='values of Residuals')
dev.off()
bitmap(file='test6.png')
densityplot(~resid,col='black',main='Residual Density Plot', xlab='values of Residuals')
dev.off()
bitmap(file='test7.png')
qqnorm(resid, main='Residual Normal Q-Q Plot')
qqline(resid)
dev.off()
ncols <- length(selection[[1]][1,])
nrows <- length(selection[[2]][,1])-1
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'ARIMA Parameter Estimation and Backward Selection', ncols+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Iteration', header=TRUE)
for (i in 1:ncols) {
a<-table.element(a,names(selection[[3]][[1]]$coef)[i],header=TRUE)
}
a<-table.row.end(a)
for (j in 1:nrows) {
a<-table.row.start(a)
mydum <- 'Estimates ('
mydum <- paste(mydum,j)
mydum <- paste(mydum,')')
a<-table.element(a,mydum, header=TRUE)
for (i in 1:ncols) {
a<-table.element(a,round(selection[[1]][j,i],4))
}
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'(p-val)', header=TRUE)
for (i in 1:ncols) {
mydum <- '('
mydum <- paste(mydum,round(selection[[2]][j,i],4),sep='')
mydum <- paste(mydum,')')
a<-table.element(a,mydum)
}
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,'Estimated ARIMA Residuals', 1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Value', 1,TRUE)
a<-table.row.end(a)
for (i in (par4*par5+par3):length(resid)) {
a<-table.row.start(a)
a<-table.element(a,resid[i])
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable1.tab')