Professional Documents
Culture Documents
PENGANTAR
TIME SERIES ANALYSIS:
Konsep dan Pemodelan
Pertemuan I / 2022
PENDAHULUAN
For Better Official Statistics
Types of Data
▪ Cross-Section
▪ Time Series
▪ Longitudinal/Panel
3
For Better Official Statistics
Cross-Sectional Data
Cross-sectional
data are
observations
collected at a
single point in
time
4
For Better Official Statistics
Time Series Data
5
For Better Official Statistics
Panel Data
6
For Better Official Statistics
Stochastic Process vs. Time Series
7
For Better Official Statistics
Two General “Classes” of Processes
✓ Stationary
▪ Unconditional mean and variance constant
▪ Time-invariant covariance
✓ Nonstationary
8
For Better Official Statistics
Stationary Processes?
9
For Better Official Statistics
Nonstationary Time Series
10
For Better Official Statistics
Modelling Time Series Data
Case 1 Case 2
Sales predicted by sales pattern in the past Sales predicted by other relevant variables
https://exceldashboardschool.com/sales-forecast-chart/ https://www.sganalytics.com/blog/choosing-right-price-elasticity-model/
✓ Causal Methods
▪ Eksplanatoris atau kausalitas, yakni menganalisis hubungan antar variabel time series
▪ Mengestimasi parameter-parameter hubungan antar variabel ekonomi, seperti elastisitas,
propensitas, multiplier, dsb dengan menggunakan data time series
12
For Better Official Statistics
Classification of Forecasting Methods
Forecasting Method
Survey
Exponential Smoothing Neural Networks
Trend Decomposition
Sales Force Composite
ARIMA
Neural Networks
References: Makridakis et al; Hanke and Reitsch; Wei, W.W.S.; and Box, Jenkins and Reinsel
For Better Official Statistics
Classification of
Forecasting Methods [2]
Most frequently searched forecasting methods Distribution of most frequently searched forecasting
according to Google Scholar over time topics according to Google Scholar over time
Model implementation
(the actual forecast)
4
5 Forecast evaluation
18
For Better Official Statistics
Data Manipulation and 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
✓ Atasi “missing data”, dengan interpolasi, deleting cases, dsb
✓ Cek kembali nilai-nilai ekstrim (terlalu tinggi atau terlalu rendah)
✓ Agregasi/Disagregasi data. Pahami data stock (posisi) atau data flow (aliran); bisa
diagregasi atau tidak. Misal jumlah penduduk (posisi), nilai produksi (flow, bisa diagregasi)
✓ dll.
19
For Better Official Statistics
Model Building and Evaluation
20
STEP 1
EKSPLORASI POLA
DATA
For Better Official Statistics
Eksplorasi Pola Data
The first step is visual inspection: graph and observe your data
22
For Better Official Statistics
Pola Umum Data Time Series
Sebelum memilih model time series yang tepat, pertama kali yang dilakukan adalah
mengeksplorasi pola data.
✓ Pola horizontal (stasioner pada rata-rata)
✓ Pola trend
✓ Pola seasonal
✓ Pola cyclical
23
For Better Official Statistics
Pola Horizontal
24
For Better Official Statistics
Pola Trend
0
2011Q1 2011Q2 2011Q3 2011Q4 2012Q1 2012Q2 2012Q3 2012Q4 2013Q1 2013Q2 2013Q3 2013Q4 2014Q1 2014Q2 2014Q3 2014Q4
-1
-2
-3
A seasonal pattern occurs when a time series is affected by seasonal factors such as the time of the
year or the day of the week. Seasonality is always of a fixed and known frequency.
26
For Better Official Statistics
Pola Cyclic
A cycle occurs when the data exhibit rises and falls that are not of a fixed frequency.
27
For Better Official Statistics
Pola Kombinasi
▪ The monthly housing sales (left) show strong seasonality within each year, as well as some strong cyclic
behaviour with a period of about 6–10 years. There is no apparent trend in the data over this period.
▪ The Australian quarterly electricity production (right) shows a strong increasing trend, with strong seasonality.
There is no evidence of any cyclic behaviour here. 28
For Better Official Statistics
Pola Kombinasi [2]
29
STEP 2
MEMILIH TEKNIK
PERAMALAN
For Better Official Statistics
Forecasting Methods
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.
32
For Better Official Statistics
Smoothing Methods
Tujuan untuk mengurangi komponen irregular sehingga komponen trend, seasonal, dan cyclic
lebih jelas terlihat
33
For Better Official Statistics
Time Series Decomposition
34
For Better Official Statistics
Stochastic Models
Stochastic Model: bersifat probabilistik, ada asumsi-asumsi tertentu pada error term
✓ Models for stationary data: AR, MA, ARMA
✓ Models for non-stationary data: ARIMA, SARIMA
35
For Better Official Statistics
Choosing a Forecasting Technique
36
STEP 3
EVALUASI
AKURASI MODEL
For Better Official Statistics
Forecast Evaluation – General Idea
38
For Better Official Statistics
Example 1
✓ Background: 21 Dec 2012 (Friday) - the end of a long cycle according to the Mayan calendar
✓ Resulting weather forecast:
Is it a good forecast? 39
For Better Official Statistics
Example 2
41
For Better Official Statistics
Lucky or Wrong
✓ Economic variables are random processes and therefore each has a probability
distribution
✓ We call that distribution, which is typically unknown, the “data generation process
(DGP)” of that variable
✓ If the variable can have continuous values, the probability of a single point
forecast being equal to the eventual outcome is zero
✓ Therefore, it is only possible to attach a probability to a range of possible
outcomes encompassing the actual outcome
✓ If a point forecast happens to be equal to the actual outcome, it is purely by
chance and quite unlikely to be repeated in the next period
42
For Better Official Statistics
Data Generation Process
43
For Better Official Statistics
Why Conditional Means?
44
For Better Official Statistics
Assuming that Conditional Mean is Known
45
For Better Official Statistics
Source of Forecast Uncertainty #1
✓ Even if we know the conditional mean, our conditional forecast will necessarily
differ from the outcome
✓ Indeed, the observed forecast errors will obviously reflect the distribution of the
true error term, which is normally unknown
✓ The best we can hope for is that, on average, our actual forecast errors are zero.
Why?
𝑦𝑡+1 = 𝐸 𝑦𝑡+1 | 𝐼𝑛𝑓𝑜𝑟𝑚𝑎𝑡𝑖𝑜𝑛𝑡 + 𝜀𝑡+1
✓ Recall that with as 𝑁 → ∞,
σ𝑛𝑡=1 𝜀𝑡
→0
𝑁 𝑝
46
For Better Official Statistics
Additional Sources of Forecast Uncertainty
✓ We will continue with our maintained assumption that the conditional mean is
known and correctly specified
✓ However, now assume it depends on a set of variables, X:
𝑦𝑡+1 = 𝐹 𝑋𝑡+1 ; 𝜃 + 𝜀𝑡+1
✓ These variables might be jointly determined within the same system (economic
model), or be determined outside of the system (exogenous)
✓ The right-hand side or explanatory variables, 𝑋𝑡 , will need to be forecasted using
additional equations, namely:
𝑋𝑡+1 = 𝐺 𝑍𝑡+1 ; 𝛽 + 𝑢𝑡+1
47
For Better Official Statistics
Source of Forecast Uncertainty #2
48
For Better Official Statistics
What if Parameters of DGP are Unknown
✓ We will continue with our maintained assumption that the conditional mean is
known
✓ However, let’s now assume that we don’t know the values of the parameters on X,
namely 𝜃
𝑦𝑡+1 = 𝐹 𝑋𝑡+1 ; 𝜃 + 𝜀𝑡+1
49
For Better Official Statistics
Source of Forecast Uncertainty #3
✓ The unknown parameters need to be estimated from the available data, which are
random
✓ It follows that the estimates of 𝜃 are necessarily random variables and therefore
can contribute to your forecast errors
✓ Why? Estimates of the unknown parameters will typically be different from their
true values: 𝜃መ ≠ 𝜃
50
For Better Official Statistics
More Sources of Forecast Uncertainty
51
For Better Official Statistics
What We Learned
52
For Better Official Statistics
How to Measure Forecast Uncertainty
53
For Better Official Statistics
Measures of Forecast Uncertainty
54
For Better Official Statistics
Common Statistical Measures
✓ Bias: the difference between the forecasts and the correct outcome (on average)
✓ Variance (“standard forecast error, SE”): A narrow range of outcomes is
compatible with the forecast
✓ Mean Squared Forecast Error (MSFE): A combination of bias and variance that is
commonly reported in forecast comparisons
The smaller they are the better the forecast
55
For Better Official Statistics
Measures of Forecast Accuracy
𝑓
1 ✓ Bias : The average of the forecast errors
𝐵𝐼𝐴𝑆 = 𝐹𝐸𝑡 di mana 𝐹𝐸𝑡 = 𝑦ො𝑡 − 𝑦𝑡
𝑓 ✓ SE : Standard forecast error
𝑡=1
✓ MSE : Mean Squared Error
𝑓
1 ✓ RMSE : Root Mean Squared Error
𝑆𝐸 = 𝐹𝐸𝑡 − 𝐵𝐼𝐴𝑆 2
𝑓 ✓ MAE : Mean Absolute Error
𝑡=1
✓ MAPE : Mean Absolute Percentage Error
𝑓
1
𝑀𝑆𝐸 = 𝐹𝐸𝑡2
𝑓
𝑡=1
𝑓
1
𝑅𝑀𝑆𝐸 = 𝐹𝐸𝑡2
𝑓
𝑡=1
𝑓 𝑓
1 1 𝐹𝐸𝑡
𝑀𝐴𝐸 = 𝐹𝐸𝑡 𝑀𝐴𝑃𝐸 =
𝑓 𝑓 𝑦𝑡
𝑡=1 𝑡=1 56
For Better Official Statistics
Forecast Strategies
▪ Rolling window
o The size of estimation sample (w) is chosen initially and fixed. 𝑤 can be less than 𝑇
o A model is estimated in [𝑇 − 𝑤 + 1, 𝑇] and a forecast is for 𝑇 + ℎ
o At 𝑇 + 1 the model is re-estimated on [𝑇 − 𝑤 + 2, 𝑇 + 1] and a forecast is made for 𝑇 + ℎ + 1
o Estimation sample rolls forward: get data, re-estimate, forecast
o Again, forecasts are made for the same horizon! Helps you deal with structural breaks too! 57
For Better Official Statistics
Expanding vs. Rolling (Sliding) Window
58
POLITEKNIK STATISTIKA STIS
For Better Official Statistics
Terima Kasih!