0% found this document useful (0 votes)
31 views

Chapter 7

This document discusses various time-series forecasting models including moving average, exponential smoothing, regression, and ARIMA. It provides an introduction and examples of each model. For moving average, it demonstrates a 3-year moving average on housing unit data. For exponential smoothing, it explains the weighted moving average concept. For regression, it implements a linear trend regression model in Python. Finally, it introduces the ARIMA model combining auto regression, moving average, and differencing approaches.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Chapter 7

This document discusses various time-series forecasting models including moving average, exponential smoothing, regression, and ARIMA. It provides an introduction and examples of each model. For moving average, it demonstrates a 3-year moving average on housing unit data. For exponential smoothing, it explains the weighted moving average concept. For regression, it implements a linear trend regression model in Python. Finally, it introduces the ARIMA model combining auto regression, moving average, and differencing approaches.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Contents

7.1. Introduction to forecasting


7.2. Time-series with moving average
7.3 Time-series with exponential smoothing
7.4 Time-series forecasting with regression
PHÂN TÍCH DỮ LIỆU
7.5 Time-series forecasting with ARIMA
BẰNG PYTHON
Lecture 7: Time-series analysis
and forecasting

7.1 Introduction to forecasting 7.1 Introduction to forecasting


 Which models for the forecasting of time-series?
– There are many forecasting models available
 Moving average

 Exponential smoothing

o o* o* ? o* o*  Regression
o * o o*
* Model 1 * Model 2  ARIMA

Which model
performs better?
7.1 Introduction to forecasting 7.1 Introduction to forecasting
 To choose a forecasting method, we can evaluate forecast  Choose SSE if it is important to avoid (even a few) large
accuracy using the actual time series. errors.
• The two most commonly-used measures of  Otherwise, use MAD.
n
forecast accuracy are: y −F  t t • A useful procedure for model selection
– mean absolute deviation MAD = t =1 – Use some of the observations to develop several
n
competing forecasting models.
n
– sum of squares for forecast error SSE = (y t − Ft )2 – Run the models on the rest of the observations.
t =1 – Calculate the accuracy of each model.
– Select the model with the best accuracy measure.

7.1 Introduction to forecasting 7.2 Moving average

 Example  Used for Smoothing


 Annual data from 1963 to 1990 were used to develop  Series of Arithmetic Means Over Time
three forecasting models.  Result Dependent Upon Choice of L (Length of Period
 Use MAD and SSE to determine which model for Computing Means)
performed best for 1991, 1992, 1993 & 1994.  To Smooth Out Cyclical Component, L Should Be
Forecast value Multiple of the Estimated Average Length of the Cycle
Year Actual y Model 1 Model 2 Model 3  For Annual Time Series, L Should Be Odd
1991 129 136 118 130
1992 142 148 141 146
1993 156 150 158 170
1994 183 175 163 180
7.2 Moving average 7.2 Moving average - Example

 Example: 3-Year Moving Average John is a building contractor with a record of a total of
24 single family homes constructed over a 6-year
Y1 + Y2 + Y3 period. Provide John with a 3-year moving average
 First average: MA(3) = graph.
3
Year Units Moving Ave
Y + Y3 + Y4
 Second average: MA (3) = 2
3 1994 2 NA
1995 5 NA
1996 2 3
1997 2 3
1998 7 3.67
1999 6 5

7.2 Moving average 7.2 Moving average

 Implementation with Python


7.2 Time-series forecasting with moving 7.2 Time-series forecasting with moving
average average
 Implementation with Python  Implementation with Python

7.3 Time-series forecasting with exponential 7.3 Time-series forecasting with exponential
smoothing weight - example
 Weighted Moving Average
 Weights decline exponentially
 Most recent observation weighted most
 Used for Smoothing and Short-Term Forecasting
 Weights are:
 Subjectively chosen
 Range from 0 to 1
- Close to 0 for smoothing out unwanted cyclical
and irregular components
- Close to 1 for forecasting
7.2 Time-series forecasting with moving 7.2 Time-series forecasting with moving
average average
 Implementation with Python  Implementation with Python

7.4 Time-series forecasting with regression 7.4 Time-series forecasting with regression
(linear trend model) (linear trend model)

Output
7.4 Time-series forecasting with regression 7.4 Time-series forecasting with regression
(linear trend model) (linear trend model)
 Implementation with Python  Implementation with Python

7.4 Time-series forecasting with regression 7.4 Time-series forecasting with regression
(linear trend model) (linear trend model)
 Implementation with Python  Implementation with Python
7.4 Time-series forecasting with regression 7.5 Time-series forecasting with ARIMA
(linear trend model)
 Implementation with Python  Problems
16
14
12
10
8

Y (t)
6
4
2
0
-2 0 10 20 30 40 50
t

16
14
12 Compare
10
8

Y (t)
6
4
2
0
-5 -2 0 5 10 15
Y (t-1)

7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Introduction of ARIMA model: ARIMA models combine two  For an example


models and 1 method.
 Auto regression (AR)  ARIMA(1, 1, 2) can also be called a damped-trend linear
 Moving Average (MA) exponential smoothing where we are applying one time
 One method is differencing (I) -> Stationary for time-series differencing on the time series if it is non-stationary
 To make a better explanation of ARIMA we can also write it
and after that, we are performing autoregression on
as (AR, I, MA) and by this, we can assume that in the ARIMA,
p is AR, d is I and q is MA. This is called an “ARIMA(p,d,q)” the series with one lag when the series is stationary by
 p is the number of autoregressive terms, differencing and 2 average moving average order is
 d is the number of nonseasonal differences,
applied.
 q is the number of lagged forecast errors in the prediction
equation.
7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA
7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA
 How to choose values of p, d and q? there are various ways to
choose the values of parameters of the ARIMA model.
 Test for stationarity using the augmented dickey fuller test.
 If the time series is stationary try to fit the ARMA model,
and if the time series is non-stationary then seek the value
of d.
In words, we can explain this expression as,  If the data is getting stationary then draw the
autocorrelation and partial autocorrelation graph of the
Prediction = constant + linear combination lags of Y + linear data.
combination of lagged forecast errors.  Draw a partial autocorrelation graph(ACF) of the data. This
will help us in finding the value of p because the cut-off
point to the PACF is p.
 Draw an autocorrelation graph(ACF) of the data. This will
help us in finding the value of q because the cut-off point to
the ACF is q.

7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Implementation of ARIMA  Implementation of ARIMA


7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Implementation of ARIMA  Implementation of ARIMA

7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Implementation of ARIMA  Implementation of ARIMA


7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Implementation of ARIMA

7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Implementation of ARIMA  Implementation of ARIMA


7.5 Time-series forecasting with ARIMA 7.5 Time-series forecasting with ARIMA

 Implementation of ARIMA  Implementation of ARIMA

Hỏi & Đáp

Cám ơn các bạn đã lắng nghe.

47

You might also like