PENGANTAR
TIME SERIES ANALYSIS:
POLITEKNIK STATISTIKA STIS
Pertemuan I / 2022
For Better Official Statistics
Konsep dan Pemodelan
Nasrudin
Forecasting
• Mengapa diperlukan?
• Bagaimana caranya?
Econometrics Quotes
Dear past, thank you for all the lessons.
Dear future, I am ready.
Don't let us use a method inappropriately, as Zorro is wrong in wearing a mask
I have seen the future and it is just like the present ,
only longer.
Kehlog Albran (1973)
DATA
4
For Better Official Statistics
▪ Cross-Section
▪ Time Series
▪ Panel
Pemodelan & Peramalan dengan Data Time Series
Case 2 Sales predicted by other variables that affect it
Case 1 Sales predicted by sales pattern in the past
https://exceldashboardschool.com/sales-forecast-chart/
https://www.sganalytics.com/blog/choosing-right-price-elasticity-model/
SALE t = a + b.SALE t-1 +et SALEt = a + b.t + c.t 2 +et
SALE t = a + b.PRICE t +et
SALE t = a + b.PRICE t +c.ADV t +et
Analisis Time Series
• Time Series Forecasting ➔ pertemuan 1-7
• Menjelaskan pola data berdasarkan waktu
• Memprediksi kejadian yang akan datang berdasarkan perilaku variabel tersebut di masa lalu
• (Classical) Econometrics
• Eksplanatoris atau causality, yakni menganalisis hubungan antar variabel time series
• Mengestimasi parameter-parameter hubungan antar variabel ekonomi, seperti elastisitas, propensitas, multiplier, dsb
menggunakan data time series
Okun’s Law
Percenta ge change in real GDP
Change in unemployment rate -4
-2 0 2 4 6 8 10
-3 -2 -1 0 1 2 3 4
1975 1991 1982
2001 1984
1951 1966
2003
1987
3.5 2
Y = −
Y u
Classification of Forecasting Methods
Forecasting Method
Objective
Forecasting Methods Subjective (Judgmental)
Forecasting Methods
Time Series
Methods Causal
Methods Analogies
Delphi
PERT
Survey techniques Simple Regression
Multiple Regression Neural Networks Naïve Methods
Moving Averages Exponential Smoothing
Trend Decomposition ARIMA
Neural Networks
Combination of Time Series –Causal Methods
VAR, VECM
Intervention Model
Transfer Function (ARIMAX)
VARIMA (VARIMAX)
Neural Networks
References:
Makridakis et al. Hanke and Reitsch Wei, W.W.S. Box, Jenkins and Reinsel
Pemodelan dan peramalan
Five steps in the forecasting process (Hanke, 2014):
• Problem formulation and data collection
• Data manipulation and cleaning
• Model building and evaluation
• Model implementation (the actual forecast)
• Forecast evaluation
Determining whether data will be useful (Hanke, 2014) :
• Data should be reliable and accurate. Proper care must be taken that data are col- lected from a reliable source with proper attention given to
accuracy.
• Data should be relevant. The data must be representative of the circumstances for which they are being used.
• Data should be consistent. When definitions concerning data collection change, adjustments need to be made to retain consistency in historical patterns. This can be a problem, for example, when government agencies change the mix or “market basket” used in determining a cost-of-living index. Years ago personal computers were not part of the mix of products being purchased by consumers; now they are.
• Data should be timely. Data collected, summarized, and published on a
timely basis will be of greatest value to the forecaster. There can be too
little data (not enough history on which to base future outcomes) or too
much data (data from irrelevant historical periods far in the past).
Data manipulation & cleaning :
• Periksa kesamaan periode waktu: menit, harian, pekanan, bulanan, triwulanan, tahunan. Jika belum sama, maka disamakan.
• Periksa kesamaan satuan (unit) dan tahun dasar. Jika belum sama, maka disamakan
• Mengatasi “missing data”, dengan interpolasi, deleting cases, dsb
• Mengecek kembali nilai-nilai ekstrim (terlalu tinggi atau terlalu rendah)
• Agregasi/Disagregasi. Pahami data stock (posisi) atau data flow (aliran);
bisa diagregasi atau tidak. Misal nilai tukar (posisi), nilai produksi (flow, bisa diagregasi)
• dll
Model building and evaluation:
• Eksplorasi pola data
• Memilih teknik peramalan
• Evaluasi model: perkiraan akurasi ramalan
Eksplorasi Pola Data
19
For Better Official Statistics
Pola Umum Data Time Series
Sebelum memilih model time series yang tepat, pertama kali yang
dilakukan adalah mengeksplorasi pola data.
(i) Stasioner vs Tidak Stasioner
Pola Data tidak stasioner
✓Tidak Stasioner pada Rata-
rata ✓ Tidak Stasioner pada Varians
Case-1: manakah pola data yang stasioner/tidak stasioner
80,00 85,00 90,00 95,00 100,00 105,00 110,00 115,00 120,00 125,00
1 2 3 4 5 6 7 8 9 101112 1 2 3 4 5 6 7 8 9 101112 1 2 3 4 5 6 7 8 9 101112 1 2 3 4 5 6 7 8 9 101112 1 2 3 4 5 6 7 8
Indeks
Indeks
Case-2: Indeks Produksi, pola data stasioner atau tidak?
Case-3: Pola data stasioner/tidak stasioner?
(ii) Dekomposisi Data Time Series
• Komponen jangka panjang: trend dan siklus (cyclical)
• Komponen jangka pendek: musiman (seasonal)
• Komponen random: irregular, tidak tertangkap oleh pola
Dekomposisi Data Time Series & Stasioneritas
• Trend -> tdk stasioner
• Seasonal ->stasioner
• Trend & seasonal-> tdk stasioner
Trend dan Cyclic
28
For Better Official Statistics
Trend dan Cyclic
Seasonal
30
For Better Official Statistics
Seasonal atau Calender Variation?
31
For Better Official Statistics
Seasonal atau Calender Variation?
Memilih Teknik Peramalan
Forecasting technique (in this course) :
• Subjective
• Objective
• Causal Method
• Time Series Forecasting
• Deterministic Model
✓ Smoothing methods
✓ Time Series Decomposition
• Stochastic (Statistical) Model
✓ Models for stationary data
✓ Models for non-stationary data
To select the appropriate forecasting technique properly, the
forecaster must be able to accomplish the following: (see Hanke, 2014: 32-34)
• Define the nature of the forecasting problem.
• Explain the nature of the data under investigation.
• Describe the capabilities and limitations of potentially useful forecasting techniques.
• Develop some predetermined criteria on which the selection decision can be
made.
Smoothing Method
tujuan untuk mengurangi komponen irregular sehingga
komponen trend, seasonal, dan cyclic lebih jelas terlihat
Prinsip dasar dekomposisi time series adalah
menguraikan data time
series ke dalam komponen-
komponen pembentuknya,
agar dapat dipahami lebih
baik serta dapat digunakan
untuk peramalan
Stochastic models (in this course) :
• Stochastic Model: bersifat probabilistic, ada asumsi-asumsi tertentu tentang error.
✓ Models for stationary data: AR, MA, ARMA
✓ Models for non-stationary data: ARIMA, SARIMA
Evaluation:
Measuring Forecast Accuracy
Mengukur Kesalahan Peramalan
• Bias - The arithmetic sum of the errors
• MAD - Mean Absolute Deviation
• MAPE – Mean Absolute Percentage Error
• MSE - Mean Square Error - Similar to simple sample variance
Makridakis (pp 43)
• Simbol yg lain, lihat Hanke, Business Forecasting
T F
Y Bias
t t
T
t
/ ) (
/T error) (forecast
1 T
1 t
−
=
=
=
=
) ( Forecast Error = Y t − F t
T F
Y
MAD
t tT
t
/
|
| /T
| error forecast
|
1
T
1 t
−
=
=
= =
T Y
F Y
MAPE
t t tT
t
/ ] /
| [|
100
1
−
=
=
T F
Y MSE
t t
T
t
/ ) (
/T
| error forecast
|
2 1
T
1 t
2
−
=
=
=
=
Pemilihan Metode Peramalan Terbaik
Waktu Data Metode A Metode B Metode C
2020.01 12 9,5 12,0 12,0
2020.02 12 11,0 12,0 12,0
2020.03 14 12,5 12,7 12,0
2020.04 13 14,0 13,0 14,0
2020.05 15 15,5 14,0 13,0
2020.06 16 17,0 14,7 15,0
2020.07 19 18,5 16,7 16,0
2020.08 17 20,0 17,3 19,0
2020.09 19 21,5 18,3 17,0
2020.10 21 23,0 19,0 19,0
2020.11 20 24,5 20,0 21,0
2020.12 23 26,0 21,3 20,0
2021.01 26 27,5 23,0 23,0
2021.02 22 29,0 23,7 26,0
2021.03 27 30,5 25,0 22,0
2021.04 25 32,0 24,7 27,0
2021.05 29 33,5 27,0 25,0
2021.06 32 35,0 28,7 29,0
2021.07 35 36,5 32,0 32,0
2021.08 36 38,0 34,3 35,0
2021.09 39,5 35,5 36,0
Forecast
Waktu Data Metode A Metode B Metode C Metode A Metode B Metode C
2020.01 12 9,5 12,0 12,0 0,20833333 0 0
2020.02 12 11,0 12,0 12,0 0,08333333 0 0
2020.03 14 12,5 12,7 12,0 0,10714286 0,0952381 0,14285714
2020.04 13 14,0 13,0 14,0 0,07692308 0 0,07692308
2020.05 15 15,5 14,0 13,0 0,03333333 0,06666667 0,13333333
2020.06 16 17,0 14,7 15,0 0,0625 0,08333333 0,0625
2020.07 19 18,5 16,7 16,0 0,02631579 0,12280702 0,15789474
2020.08 17 20,0 17,3 19,0 0,17647059 0,01960784 0,11764706
2020.09 19 21,5 18,3 17,0 0,13157895 0,03508772 0,10526316
2020.10 21 23,0 19,0 19,0 0,0952381 0,0952381 0,0952381
2020.11 20 24,5 20,0 21,0 0,225 0 0,05
2020.12 23 26,0 21,3 20,0 0,13043478 0,07246377 0,13043478
2021.01 26 27,5 23,0 23,0 0,05769231 0,11538462 0,11538462
2021.02 22 29,0 23,7 26,0 0,31818182 0,07575758 0,18181818
2021.03 27 30,5 25,0 22,0 0,12962963 0,07407407 0,18518519
2021.04 25 32,0 24,7 27,0 0,28 0,01333333 0,08
2021.05 29 33,5 27,0 25,0 0,15517241 0,06896552 0,13793103
2021.06 32 35,0 28,7 29,0 0,09375 0,10416667 0,09375
2021.07 35 36,5 32,0 32,0 0,04285714 0,08571429 0,08571429
2021.08 36 38,0 34,3 35,0 0,05555556 0,0462963 0,02777778
2021.09 39,5 35,5 36,0
2,489443 1,1741349 1,97965246 Jumlah
20 20 20 waktu (T)
0,12447215 0,05870675 0,09898262 MAPE
12,45 5,87 9,90 MAPE(%)
(TERBAIK)
Forecast abs(Y-F)/Y
Pemilihan Metode Peramalan Terbaik
Data training vs Data testing
Waktu Data Metode A Metode B Metode C
2020.01 12 9,5 12,0 12,0
2020.02 12 11,0 12,0 12,0
2020.03 14 12,5 12,7 12,0
2020.04 13 14,0 13,0 14,0
2020.05 15 15,5 14,0 13,0
2020.06 16 17,0 14,7 15,0
2020.07 19 18,5 16,7 16,0
2020.08 17 20,0 17,3 19,0
2020.09 19 21,5 18,3 17,0
2020.10 21 23,0 19,0 19,0
2020.11 20 24,5 20,0 21,0
2020.12 23 26,0 21,3 20,0
2021.01 26 27,5 23,0 23,0
2021.02 22 29,0 23,7 26,0
2021.03 27 30,5 25,0 22,0
2021.04 25 32,0 24,7 27,0
2021.05 29 33,5 27,0 25,0
2021.06 32 35,0 28,7 29,0
2021.07 35 36,5 32,0 32,0
2021.08 36 38,0 34,3 35,0
2021.09 39,5 35,5 36,0
Forecast
Data Training (in Sample): 80% =>
Fitting Model
Data Testing (Out Sampel): 20% =>
validasi
Get the pattern,
predict the future
Prinsip dasar time series forecasting:
Berikut gambar-gambar
pola data time series .
Temukan polanya dan
bagaimana cara mem-forecasting-nya
Example: De-Seasonalizing
Fit a regression line to the deseasonalized observations – y’ (using time as the
independent variable).
Keterangan : Data penjualan SARDEN di PT Blambangan Jaya, Banyuwangi
Reference: Badan Pusat Statistik (BPS) Indonesia Krisis di Indonesia
Pertengahan 1997
Reference: Badan Pusat Statistik (BPS) Bali