introduction to forecasting - rob j hyndman
TRANSCRIPT
Forecasting using
1. Introduction to forecasting
OTexts.com/fpp/1/OTexts.com/fpp/2/3
Forecasting using R 1
Rob J Hyndman
Outline
1 Introduction
2 Some case studies
3 Time series data
4 Some simple forecasting methods
5 Conclusion
Forecasting using R Introduction 2
The online environment
Forecasting using R Introduction 3
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer sales
Brief bio
Forecasting using R Introduction 4
Director of Monash University’sBusiness & EconomicForecasting Unit
Editor-in-Chief, InternationalJournal of Forecasting
How my forecasting methodology is used:
Pharmaceutical Benefits Scheme
Cancer incidence and mortality
Electricity demand
Ageing population
Fertilizer salesrobjhyndman.com
Introductions
Please introduce yourself briefly using the chat box(be sure to send your message to everyone).
What is your name?
Where in the world are you?
What time is it there?
Why are you taking this course?
Example
Rob. Melbourne, Australia. 9am. To help me use Rfor forecasting sales for my company.
Forecasting using R Introduction 5
Introductions
Please introduce yourself briefly using the chat box(be sure to send your message to everyone).
What is your name?
Where in the world are you?
What time is it there?
Why are you taking this course?
Example
Rob. Melbourne, Australia. 9am. To help me use Rfor forecasting sales for my company.
Forecasting using R Introduction 5
Poll: How experienced are you in forecasting?
1 Guru: I wrote the book, done it for decades,now I do the conference circuit.
2 Expert: It has been my full time job for morethan a decade.
3 Skilled: I have been doing it for years.
4 Comfortable: I understand it and have done it.
5 Learner: I am still learning.
6 Beginner: I have heard of it and would like tolearn more.
7 Unknown: What is forecasting? Is that what theweather people do?
Forecasting using R Introduction 6
Key reference
Hyndman, R. J. & Athanasopoulos, G.
(2013) Forecasting: principles and
practice.
otexts.com/fpp/
Free and online
Data sets in associated R package
R code for examples
Forecasting using R Introduction 7
Key reference
Hyndman, R. J. & Athanasopoulos, G.
(2013) Forecasting: principles and
practice.
otexts.com/fpp/
Free and online
Data sets in associated R package
R code for examples
Forecasting using R Introduction 7
Key reference
Hyndman, R. J. & Athanasopoulos, G.
(2013) Forecasting: principles and
practice.
otexts.com/fpp/
Free and online
Data sets in associated R package
R code for examples
Forecasting using R Introduction 7
Key reference
Hyndman, R. J. & Athanasopoulos, G.
(2013) Forecasting: principles and
practice.
otexts.com/fpp/
Free and online
Data sets in associated R package
R code for examples
Forecasting using R Introduction 7
Key reference
Hyndman, R. J. & Athanasopoulos, G.
(2013) Forecasting: principles and
practice.
otexts.com/fpp/
Free and online
Data sets in associated R package
R code for examples
Forecasting using R Introduction 7
Book recommendation
Forecasting using R Introduction 8
If you need more supporton statistics or R, then Irecommend:
Introductory Statisticswith Rby Peter Dalgaard
Poll: How proficient are you in using R?
1 Guru: The R core team come to me for advice.2 Expert: I have written several packages on
CRAN.3 Skilled: I use it regularly and it is an important
part of my job.4 Comfortable: I use it often and am comfortable
with the tool.5 User: I use it sometimes, but I am often
searching around for the right function.6 Learner: I have used it a few times.7 Beginner: I’ve managed to download and install
it.8 Unknown: Why are you speaking like a pirate?
Forecasting using R Introduction 9
Which version of R are you using?
Version: (try getRversion() if you don’t know)
1 R 3.0.0 or higher
2 R 2.15.x
3 R 2.14.x
4 Something older.
Edition
1 Standard R (CRAN)
2 Standard R with RStudio
3 Revolution R: Community, EnterpriseWorkstation or Server
4 Something else?Forecasting using R Introduction 10
Install required packages
install.packages("fpp", dependencies=TRUE)
Forecasting using R Introduction 11
Getting help with R# Search for termshelp.search("forecasting")
# Detailed helphelp(forecast)
# Worked examplesexample("forecast.ar")
# Similar namesapropos("forecast")
#Help on packagehelp(package="fpp")
Forecasting using R Introduction 12
Approximate outline
Week Topic Chapter
1 The forecaster’s toolbox 1,22 Seasonality and trends 63 Exponential smoothing 74 Stationarity, transformations
and differencing2,8
5 ARIMA models 86 Time series cross-validation 26 Dynamic regression 9
Forecasting using R Introduction 13
Assumptions
This is not an introduction to R. I assume youare broadly comfortable with R code and the Renvironment.
This is not a statistics course. I assume you arefamiliar with concepts such as the mean,standard deviation, quantiles, regression,normal distribution, etc.
This is not a theory course. I am not going toderive anything. I will teach you forecastingtools, when to use them and how to use themmost effectively.
Forecasting using R Introduction 14
Assumptions
This is not an introduction to R. I assume youare broadly comfortable with R code and the Renvironment.
This is not a statistics course. I assume you arefamiliar with concepts such as the mean,standard deviation, quantiles, regression,normal distribution, etc.
This is not a theory course. I am not going toderive anything. I will teach you forecastingtools, when to use them and how to use themmost effectively.
Forecasting using R Introduction 14
Assumptions
This is not an introduction to R. I assume youare broadly comfortable with R code and the Renvironment.
This is not a statistics course. I assume you arefamiliar with concepts such as the mean,standard deviation, quantiles, regression,normal distribution, etc.
This is not a theory course. I am not going toderive anything. I will teach you forecastingtools, when to use them and how to use themmost effectively.
Forecasting using R Introduction 14
Outline
1 Introduction
2 Some case studies
3 Time series data
4 Some simple forecasting methods
5 Conclusion
Forecasting using R Some case studies 15
CASE STUDY 1: Paperware company
Forecasting using R Some case studies 16
Problem: Want forecasts of each ofhundreds of items. Series can bestationary, trended or seasonal. Theycurrently have a large forecastingprogram written in-house but it doesn’tseem to produce sensible forecasts.They want me to tell them what iswrong and fix it.
CASE STUDY 1: Paperware company
Forecasting using R Some case studies 16
Problem: Want forecasts of each ofhundreds of items. Series can bestationary, trended or seasonal. Theycurrently have a large forecastingprogram written in-house but it doesn’tseem to produce sensible forecasts.They want me to tell them what iswrong and fix it.
Additional informationProgram written in COBOL making numerical calculationslimited. It is not possible to do any optimisation.
CASE STUDY 1: Paperware company
Forecasting using R Some case studies 16
Problem: Want forecasts of each ofhundreds of items. Series can bestationary, trended or seasonal. Theycurrently have a large forecastingprogram written in-house but it doesn’tseem to produce sensible forecasts.They want me to tell them what iswrong and fix it.
Additional informationProgram written in COBOL making numerical calculationslimited. It is not possible to do any optimisation.Their programmer has little experience in numericalcomputing.
CASE STUDY 1: Paperware company
Forecasting using R Some case studies 16
Problem: Want forecasts of each ofhundreds of items. Series can bestationary, trended or seasonal. Theycurrently have a large forecastingprogram written in-house but it doesn’tseem to produce sensible forecasts.They want me to tell them what iswrong and fix it.
Additional informationProgram written in COBOL making numerical calculationslimited. It is not possible to do any optimisation.Their programmer has little experience in numericalcomputing.They employ no statisticians and want the program toproduce forecasts automatically.
CASE STUDY 1: Paperware company
Methods currently used
A 12 month average
C 6 month average
E straight line regression over last 12 months
G straight line regression over last 6 months
H average slope between last year’s and thisyear’s values.(Equivalent to differencing at lag 12 andtaking mean.)
I Same as H except over 6 months.
K I couldn’t understand the explanation.
Forecasting using R Some case studies 17
CASE STUDY 2: PBS
Forecasting using R Some case studies 18
CASE STUDY 2: PBS
The Pharmaceutical Benefits Scheme (PBS) isthe Australian government drugs subsidy scheme.
Many drugs bought from pharmacies aresubsidised to allow more equitable access tomodern drugs.
The cost to government is determined by thenumber and types of drugs purchased.Currently nearly 1% of GDP.
The total cost is budgeted based on forecastsof drug usage.
Forecasting using R Some case studies 19
CASE STUDY 2: PBS
The Pharmaceutical Benefits Scheme (PBS) isthe Australian government drugs subsidy scheme.
Many drugs bought from pharmacies aresubsidised to allow more equitable access tomodern drugs.
The cost to government is determined by thenumber and types of drugs purchased.Currently nearly 1% of GDP.
The total cost is budgeted based on forecastsof drug usage.
Forecasting using R Some case studies 19
CASE STUDY 2: PBS
The Pharmaceutical Benefits Scheme (PBS) isthe Australian government drugs subsidy scheme.
Many drugs bought from pharmacies aresubsidised to allow more equitable access tomodern drugs.
The cost to government is determined by thenumber and types of drugs purchased.Currently nearly 1% of GDP.
The total cost is budgeted based on forecastsof drug usage.
Forecasting using R Some case studies 19
CASE STUDY 2: PBS
The Pharmaceutical Benefits Scheme (PBS) isthe Australian government drugs subsidy scheme.
Many drugs bought from pharmacies aresubsidised to allow more equitable access tomodern drugs.
The cost to government is determined by thenumber and types of drugs purchased.Currently nearly 1% of GDP.
The total cost is budgeted based on forecastsof drug usage.
Forecasting using R Some case studies 19
CASE STUDY 2: PBS
Forecasting using R Some case studies 20
CASE STUDY 2: PBS
In 2001: $4.5 billion budget, under-forecastedby $800 million.Thousands of products. Seasonal demand.Subject to covert marketing, volatile products,uncontrollable expenditure.Although monthly data available for 10 years,data are aggregated to annual values, and onlythe first three years are used in estimating theforecasts.All forecasts being done with the FORECASTfunction in MS-Excel!
Problem: How to do the forecasting better?
Forecasting using R Some case studies 21
CASE STUDY 2: PBS
In 2001: $4.5 billion budget, under-forecastedby $800 million.Thousands of products. Seasonal demand.Subject to covert marketing, volatile products,uncontrollable expenditure.Although monthly data available for 10 years,data are aggregated to annual values, and onlythe first three years are used in estimating theforecasts.All forecasts being done with the FORECASTfunction in MS-Excel!
Problem: How to do the forecasting better?
Forecasting using R Some case studies 21
CASE STUDY 2: PBS
In 2001: $4.5 billion budget, under-forecastedby $800 million.Thousands of products. Seasonal demand.Subject to covert marketing, volatile products,uncontrollable expenditure.Although monthly data available for 10 years,data are aggregated to annual values, and onlythe first three years are used in estimating theforecasts.All forecasts being done with the FORECASTfunction in MS-Excel!
Problem: How to do the forecasting better?
Forecasting using R Some case studies 21
CASE STUDY 2: PBS
In 2001: $4.5 billion budget, under-forecastedby $800 million.Thousands of products. Seasonal demand.Subject to covert marketing, volatile products,uncontrollable expenditure.Although monthly data available for 10 years,data are aggregated to annual values, and onlythe first three years are used in estimating theforecasts.All forecasts being done with the FORECASTfunction in MS-Excel!
Problem: How to do the forecasting better?
Forecasting using R Some case studies 21
CASE STUDY 2: PBS
In 2001: $4.5 billion budget, under-forecastedby $800 million.Thousands of products. Seasonal demand.Subject to covert marketing, volatile products,uncontrollable expenditure.Although monthly data available for 10 years,data are aggregated to annual values, and onlythe first three years are used in estimating theforecasts.All forecasts being done with the FORECASTfunction in MS-Excel!
Problem: How to do the forecasting better?
Forecasting using R Some case studies 21
CASE STUDY 2: PBS
In 2001: $4.5 billion budget, under-forecastedby $800 million.Thousands of products. Seasonal demand.Subject to covert marketing, volatile products,uncontrollable expenditure.Although monthly data available for 10 years,data are aggregated to annual values, and onlythe first three years are used in estimating theforecasts.All forecasts being done with the FORECASTfunction in MS-Excel!
Problem: How to do the forecasting better?
Forecasting using R Some case studies 21
CASE STUDY 3: Airline
Forecasting using R Some case studies 22
CASE STUDY 3: Airline
Forecasting using R Some case studies 23
First class passengers: Melbourne−Sydney
Year
1988 1989 1990 1991 1992 1993
0.0
1.0
2.0
Business class passengers: Melbourne−Sydney
Year
1988 1989 1990 1991 1992 1993
02
46
8
Economy class passengers: Melbourne−Sydney
Year
1988 1989 1990 1991 1992 1993
010
2030
CASE STUDY 3: Airline
Forecasting using R Some case studies 23
First class passengers: Melbourne−Sydney
Year
1988 1989 1990 1991 1992 1993
0.0
1.0
2.0
Business class passengers: Melbourne−Sydney
Year
1988 1989 1990 1991 1992 1993
02
46
8
Economy class passengers: Melbourne−Sydney
Year
1988 1989 1990 1991 1992 1993
010
2030
Not the real data!Or is it?
CASE STUDY 3: Airline
Problem: how to forecast passenger traffic onmajor routes.
Additional information
They can provide a large amount of data onprevious routes.
Traffic is affected by school holidays, specialevents such as the Grand Prix, advertisingcampaigns, competition behaviour, etc.
They have a highly capable team of people whoare able to do most of the computing.
Forecasting using R Some case studies 24
CASE STUDY 3: Airline
Problem: how to forecast passenger traffic onmajor routes.
Additional information
They can provide a large amount of data onprevious routes.
Traffic is affected by school holidays, specialevents such as the Grand Prix, advertisingcampaigns, competition behaviour, etc.
They have a highly capable team of people whoare able to do most of the computing.
Forecasting using R Some case studies 24
CASE STUDY 3: Airline
Problem: how to forecast passenger traffic onmajor routes.
Additional information
They can provide a large amount of data onprevious routes.
Traffic is affected by school holidays, specialevents such as the Grand Prix, advertisingcampaigns, competition behaviour, etc.
They have a highly capable team of people whoare able to do most of the computing.
Forecasting using R Some case studies 24
CASE STUDY 3: Airline
Problem: how to forecast passenger traffic onmajor routes.
Additional information
They can provide a large amount of data onprevious routes.
Traffic is affected by school holidays, specialevents such as the Grand Prix, advertisingcampaigns, competition behaviour, etc.
They have a highly capable team of people whoare able to do most of the computing.
Forecasting using R Some case studies 24
Outline
1 Introduction
2 Some case studies
3 Time series data
4 Some simple forecasting methods
5 Conclusion
Forecasting using R Time series data 25
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Time series data
Time series consist of sequences ofobservations collected over time.We will assume the time periods are equallyspaced.
Time series examples
Daily IBM stock pricesMonthly rainfallAnnual Google profitsQuarterly Australian beer production
Forecasting is estimating how the sequenceof observations will continue into the future.
Forecasting using R Time series data 26
Australian beer production
Forecasting using R Time series data 27
Year
meg
alite
rs
1995 2000 2005 2010
400
450
500
Looking for stories
Forecasting using R Time series data 28
Looking for stories that make sense
Forecasting using R Time series data 29
Think about what you’re doing
Forecasting using R Time series data 30
Time series in RAustralian GDPausgdp <- ts(scan("gdp.dat"),frequency=4,
start=1971+2/4)Class: tsPrint and plotting methods available.
> ausgdpQtr1 Qtr2 Qtr3 Qtr4
1971 4612 46511972 4645 4615 4645 47221973 4780 4830 4887 49331974 4921 4875 4867 49051975 4938 4934 4942 49791976 5028 5079 5112 51271977 5130 5101 5072 50691978 5100 5166 5244 53121979 5349 5370 5388 53961980 5388 5403 5442 5482
Forecasting using R Time series data 31
Time series in RAustralian GDPausgdp <- ts(scan("gdp.dat"),frequency=4,
start=1971+2/4)Class: tsPrint and plotting methods available.
> ausgdpQtr1 Qtr2 Qtr3 Qtr4
1971 4612 46511972 4645 4615 4645 47221973 4780 4830 4887 49331974 4921 4875 4867 49051975 4938 4934 4942 49791976 5028 5079 5112 51271977 5130 5101 5072 50691978 5100 5166 5244 53121979 5349 5370 5388 53961980 5388 5403 5442 5482
Forecasting using R Time series data 31
Time series in RAustralian GDPausgdp <- ts(scan("gdp.dat"),frequency=4,
start=1971+2/4)Class: tsPrint and plotting methods available.
> ausgdpQtr1 Qtr2 Qtr3 Qtr4
1971 4612 46511972 4645 4615 4645 47221973 4780 4830 4887 49331974 4921 4875 4867 49051975 4938 4934 4942 49791976 5028 5079 5112 51271977 5130 5101 5072 50691978 5100 5166 5244 53121979 5349 5370 5388 53961980 5388 5403 5442 5482
Forecasting using R Time series data 31
Time series in R
Forecasting using R Time series data 32
Time
ausg
dp
1975 1980 1985 1990 19954500
5000
5500
6000
6500
7000
7500 > plot(ausgdp)
Time series in R
Residential electricity sales
> elecsalesTime Series:Start = 1989End = 2008Frequency = 1[1] 2354.34 2379.71 2318.52 2468.99 2386.09 2569.47[7] 2575.72 2762.72 2844.50 3000.70 3108.10 3357.50
[13] 3075.70 3180.60 3221.60 3176.20 3430.60 3527.48[19] 3637.89 3655.00
Forecasting using R Time series data 33
Time series in RMain package used in this course> library(fpp)
Forecasting using R Time series data 34
Time series in RMain package used in this course> library(fpp)This loads:
some data for use in examples and exercisesforecast package (for forecasting functions)tseries package (for a few time seriesfunctions)fma package (for lots of time series data)expsmooth package (for more time seriesdata)lmtest package (for some regressionfunctions)
Forecasting using R Time series data 34
Time series in RMain package used in this course> library(fpp)This loads:
some data for use in examples and exercisesforecast package (for forecasting functions)tseries package (for a few time seriesfunctions)fma package (for lots of time series data)expsmooth package (for more time seriesdata)lmtest package (for some regressionfunctions)
Forecasting using R Time series data 34
Time series in RMain package used in this course> library(fpp)This loads:
some data for use in examples and exercisesforecast package (for forecasting functions)tseries package (for a few time seriesfunctions)fma package (for lots of time series data)expsmooth package (for more time seriesdata)lmtest package (for some regressionfunctions)
Forecasting using R Time series data 34
Time series in RMain package used in this course> library(fpp)This loads:
some data for use in examples and exercisesforecast package (for forecasting functions)tseries package (for a few time seriesfunctions)fma package (for lots of time series data)expsmooth package (for more time seriesdata)lmtest package (for some regressionfunctions)
Forecasting using R Time series data 34
Time series in RMain package used in this course> library(fpp)This loads:
some data for use in examples and exercisesforecast package (for forecasting functions)tseries package (for a few time seriesfunctions)fma package (for lots of time series data)expsmooth package (for more time seriesdata)lmtest package (for some regressionfunctions)
Forecasting using R Time series data 34
Time series in RMain package used in this course> library(fpp)This loads:
some data for use in examples and exercisesforecast package (for forecasting functions)tseries package (for a few time seriesfunctions)fma package (for lots of time series data)expsmooth package (for more time seriesdata)lmtest package (for some regressionfunctions)
Forecasting using R Time series data 34
Outline
1 Introduction
2 Some case studies
3 Time series data
4 Some simple forecasting methods
5 Conclusion
Forecasting using R Some simple forecasting methods 35
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 36
Australian quarterly beer production
meg
alite
rs
1995 2000 2005
400
450
500
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 36
Australian quarterly beer production
meg
alite
rs
1995 2000 2005
400
450
500
Can you think of any forecasting methods for these data?
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 37
Number of pigs slaughtered in Victoria
thou
sand
s
1990 1991 1992 1993 1994 1995
8090
100
110
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 37
Number of pigs slaughtered in Victoria
thou
sand
s
1990 1991 1992 1993 1994 1995
8090
100
110
How would you forecast these data?
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 38
Dow Jones index (daily ending 15 Jul 94)
0 50 100 150 200 250
3600
3700
3800
3900
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 38
Dow Jones index (daily ending 15 Jul 94)
0 50 100 150 200 250
3600
3700
3800
3900
How would you forecast these data?
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Average method
Forecast of all future values is equal to mean ofhistorical data {y1, . . . , yT}.Forecasts: yT+h|T = y = (y1 + · · ·+ yT)/T
Naïve method (for time series only)
Forecasts equal to last observed value.Forecasts: yT+h|T = yT.Consequence of efficient market hypothesis.
Seasonal naïve method
Forecasts equal to last value from same season.Forecasts: yT+h|T = yT+h−km where m =seasonal period and k = b(h− 1)/mc+1.
Forecasting using R Some simple forecasting methods 39
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 40
Forecasts for quarterly beer production
1995 2000 2005
400
450
500
Which method is which?
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 40
Forecasts for quarterly beer production
1995 2000 2005
400
450
500
Mean methodNaive methodSeasonal naive method
Which method is which?
Drift method
Forecasts equal to last value plus averagechange.
Forecasts:
yT+h|T = yT +h
T − 1
T∑t=2
(yt − yt−1)
= yT +h
T − 1(yT − y1).
Equivalent to extrapolating a line drawnbetween first and last observations.
Forecasting using R Some simple forecasting methods 41
Drift method
Forecasts equal to last value plus averagechange.
Forecasts:
yT+h|T = yT +h
T − 1
T∑t=2
(yt − yt−1)
= yT +h
T − 1(yT − y1).
Equivalent to extrapolating a line drawnbetween first and last observations.
Forecasting using R Some simple forecasting methods 41
Drift method
Forecasts equal to last value plus averagechange.
Forecasts:
yT+h|T = yT +h
T − 1
T∑t=2
(yt − yt−1)
= yT +h
T − 1(yT − y1).
Equivalent to extrapolating a line drawnbetween first and last observations.
Forecasting using R Some simple forecasting methods 41
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 42
Dow Jones Index (daily ending 15 Jul 94)
Day
0 50 100 150 200 250 300
3600
3700
3800
3900
Some simple forecasting methods
Forecasting using R Some simple forecasting methods 42
Dow Jones Index (daily ending 15 Jul 94)
Day
0 50 100 150 200 250 300
3600
3700
3800
3900
Mean methodNaive methodDrift model
Some simple forecasting methods
Mean: meanf(x, h=20)
Naive: naive(x, h=20) or rwf(x, h=20)
Seasonal naive: snaive(x, h=20)
Drift: rwf(x, drift=TRUE, h=20)
Forecasting using R Some simple forecasting methods 43
Some simple forecasting methods
Mean: meanf(x, h=20)
Naive: naive(x, h=20) or rwf(x, h=20)
Seasonal naive: snaive(x, h=20)
Drift: rwf(x, drift=TRUE, h=20)
Forecasting using R Some simple forecasting methods 43
Some simple forecasting methods
Mean: meanf(x, h=20)
Naive: naive(x, h=20) or rwf(x, h=20)
Seasonal naive: snaive(x, h=20)
Drift: rwf(x, drift=TRUE, h=20)
Forecasting using R Some simple forecasting methods 43
Some simple forecasting methods
Mean: meanf(x, h=20)
Naive: naive(x, h=20) or rwf(x, h=20)
Seasonal naive: snaive(x, h=20)
Drift: rwf(x, drift=TRUE, h=20)
Forecasting using R Some simple forecasting methods 43
Outline
1 Introduction
2 Some case studies
3 Time series data
4 Some simple forecasting methods
5 Conclusion
Forecasting using R Conclusion 44
Piazza
You should all have received an invitation tojoin the Piazza course page.
All discussion and distribution of informationoutside of classes will take place there.
Homework available there.
Session slides available there after eachsession.
Please ask questions there.
If you haven’t received an invitation, or arehaving trouble, please ask James to help([email protected]).
Forecasting using R Conclusion 45
Piazza
You should all have received an invitation tojoin the Piazza course page.
All discussion and distribution of informationoutside of classes will take place there.
Homework available there.
Session slides available there after eachsession.
Please ask questions there.
If you haven’t received an invitation, or arehaving trouble, please ask James to help([email protected]).
Forecasting using R Conclusion 45
Piazza
You should all have received an invitation tojoin the Piazza course page.
All discussion and distribution of informationoutside of classes will take place there.
Homework available there.
Session slides available there after eachsession.
Please ask questions there.
If you haven’t received an invitation, or arehaving trouble, please ask James to help([email protected]).
Forecasting using R Conclusion 45
Piazza
You should all have received an invitation tojoin the Piazza course page.
All discussion and distribution of informationoutside of classes will take place there.
Homework available there.
Session slides available there after eachsession.
Please ask questions there.
If you haven’t received an invitation, or arehaving trouble, please ask James to help([email protected]).
Forecasting using R Conclusion 45
Piazza
You should all have received an invitation tojoin the Piazza course page.
All discussion and distribution of informationoutside of classes will take place there.
Homework available there.
Session slides available there after eachsession.
Please ask questions there.
If you haven’t received an invitation, or arehaving trouble, please ask James to help([email protected]).
Forecasting using R Conclusion 45
Piazza
You should all have received an invitation tojoin the Piazza course page.
All discussion and distribution of informationoutside of classes will take place there.
Homework available there.
Session slides available there after eachsession.
Please ask questions there.
If you haven’t received an invitation, or arehaving trouble, please ask James to help([email protected]).
Forecasting using R Conclusion 45
Homework
There will be a homework sheet available foreach session to give you practice with theconcepts introduced.
Please try to do each sheet before the nextsession.
I will post answers on Piazza.
Forecasting using R Conclusion 46
Homework
There will be a homework sheet available foreach session to give you practice with theconcepts introduced.
Please try to do each sheet before the nextsession.
I will post answers on Piazza.
Forecasting using R Conclusion 46
Homework
There will be a homework sheet available foreach session to give you practice with theconcepts introduced.
Please try to do each sheet before the nextsession.
I will post answers on Piazza.
Forecasting using R Conclusion 46