Professional Documents
Culture Documents
Week 1-5
Week 1-5
Week 1-5
References
- Forecasting: Methods and Applications, 3rd Edition, 1998 by Makridakis, Wheelwright, and Hyndman, Wiley, ISBN
0-471-53233-9. (MWH)
- Business Forecasting, 9th edition, 2008 by Hanke and Wichern, ISBN 0-13-500933-2.
- Forecasting practice and Process for Demand Management, 2006 by Levenbach H. and Cleary, J. P., ISBN0-534-26268-6,
Thomson.
- Applied Econometric Time Series, by Walter Enders, 2nd Edition, Wiley 2004.
- Introduction to Time Series and Forecasting, 2nd edition, 2002 by Brockwell, P. J., and Davis, R. A. Springer-Verlag: New York,
ISBN 0-387-95351-5.
Notes
- Blue: first introduced, red/ italic: emphasized, *:technical but not tested
Data Sources
Australian Data US Data
Types of data
- time series data
- cross-sectional data (same time point, different features)
Types of forecasting
Qualitative Delphi method
(judgmental) - Assumption: forecasts from a group is more accurate than those from individuals;
forecasting - Stages: forming panel, setting tasks, initial expert views, feedback to experts, aggregating
expert views for forecasting
1. Panel of experts BUT never meet as a group.
2. Use questionnaire to obtain forecasts from all participants
3. Summarize and re-distribute results to all participants PLUS appropriate new questions
4. Summarize again, refining forecasts and conditions, and developing new questions.
5. Repeat Step 4 if necessary. Distribute the final results to all participants.
Expert opinion/ judgment (subjective): lack historical data, used in conjunction with data-based
forecasting. Subjectively extending previous patterns into future
Quantitative Based on historical data, use formal econometric or statistical forecasting methods.
(data based) Project previous patterns into the future using a statistical model.
forecasting Focus:
Time series modeling forecasts.
- A class of forecasting techniques based on time series data analysis: AR, ARMA, Recurrent
neural networks, etc.
- Project previous patterns into future using a formal statistical model
- Only concerned with forecasting, not reasons why the variable changes
Regression modeling forecasts.
- A class of forecasting techniques based on regression modeling
- Use a formal statistical regression model
- Can assess other quantities related to target changes and scenario forecasting
Data Graphing
- Visualize features: trend, correlation, relationship
- Give insights into the data
- Data type determines the graphing technique: time series and scatter plot
- Good graphs convey both patterns and randomness (message + noise) data analyst removes noise.
Python plotting
- Import matplotlib.pyplot as plt
- 1. Prepare data” loading data from file, processing and computing
2. Define a drawing window: size, subplots (default setting: plt.plot() )
3. Use the main plotting functions plot and/ or scatter etc.
Cycle Slow rises and falls that are not in a regular repeating pattern, no fixed period!
Seasonal variations Rises and falls that are in a regular repeating pattern, on a seasonal basis such as months of the
year or days of the week. (fixed period M is unchanging!)
Fixed seasonal period/ frequency is denoted by M
Irregular fluctuations Follow no visualizable pattern, need statistical models to capture, assumed unexplainable
Might be ’unusual’ events: earthquakes, accidents, hurricanes, wars, strikes
OR just random variation i.e. noise!
(after the seasonal component is removed, see the fluctuations)
Notation
- A time series of length T 𝑇 = {𝑌1, 𝑌2, 𝑌3,..., 𝑌𝑇}, 𝑜𝑟 𝑌1:𝑇 observations
Prediction methods:
1. Naїve forecasting method: Most Recent Value
2. Seasonal Naїve Method: Most Recent Season’s Value
3. Drift Method ( )
- A variant of the na ̈ıve method, allowing the changes in the forecasts over time
- The amount of change over time, called drift, is the average change seen in the historical data.
- This is equivalent to drawing a line between the first and last observation, and use that line to forecast for times after
T.
Prediction Errors and Measures
- All measures can be used simultaneously. Report the ones that can be best understood.
- If there are 1 or 2 large undesirable errors, use MSE. IF not then use MAD or MAPE
- MAD, MSE, RMSE and MAPE are suitable for numerical data.
- For categorical or direction forecasting, use percentage agreement (disagreement)
Mean Absolute Deviation (MAD) average distance between actual and forecast, i.e. average
forecast error.
- same units as Y
- Does not heavily penalize a small number of large errors
2. Forward Chaining
There are T total observations, and we wish to use at least K previous observations to build the model
(suppose T=10, K=3)
Use Y1, Y2, Y3 to build the model to predict Y4, producing e4
Use Y1, Y2, Y3, Y4 to build the model to predict Y5, producing e5
Use Y1, Y2, Y3, Y4, Y5 to build the model to predict Y6, producing e6
Use Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9 to build the model to predict Y10, producing e10
Assess the overall errors e4, e5, ..., e10 for the modeling method.
Additive decomposition: 𝑦𝑡 = 𝑇𝑡 + 𝑆𝑡 + 𝑅𝑡
- Appropriate when the variation around the trend or the seasonal pattern doesn’t change over time.
trend trend variance multi
Multiplicative decomposition: 𝑦𝑡 = 𝑇𝑡 × 𝑆𝑡 × 𝑅𝑡
- Appropriate when the variation changes over time
- Convert into a additive model with log transformation: 𝑙𝑜𝑔 𝑦𝑡 = 𝑙𝑜𝑔 𝑇𝑡 + 𝑙𝑜𝑔 𝑆𝑡 + 𝑙𝑜𝑔 𝑅𝑡 and plot the log series
Log-transformation can make reserves more constant??? Need review
Seasonal adjustment: 𝑦𝑡 = 𝑦𝑡 − 𝑆𝑡 or 𝑦𝑡 = 𝑦𝑡 / 𝑆𝑡
- Estimates (identifies) and removes the influence of predictable seasonal patterns to reveal the change in time series value
(overall trend?)
- Obtain the seasonally adjusted data when seasonal components are removed. Leads to more accurate forecast
𝑇𝑡−0.5+𝑇𝑡+0.5
- MA-k (even) example:4, 𝑇𝑡 = 2
, see t need to start from 3
𝑌𝑡−2+𝑌𝑡−1+ 𝑌𝑡 +𝑌𝑡+1 𝑌𝑡−1+𝑌𝑡+ 𝑌𝑡+1 +𝑌𝑡+2
𝑇𝑡−0.5 = 4
, 𝑇𝑡+0.5 = 4
- Selecting k: when k increases, we lose more data on both sides, larger k, soother line.
Model assumption 𝑦𝑡 = 𝑇𝑡 × 𝑆𝑡 × 𝑅𝑡 𝑦𝑡 = 𝑇𝑡 + 𝑆𝑡 + 𝑅𝑡
Trend component Data smoothing. E.g. MA-k Data smoothing. E.g. MA-k
estimation
Detrend 𝑌𝑇/n
𝑇𝑡 = 𝑆 𝑇 × 𝑅𝑡 n =𝑆 + 𝑅
𝑌𝑇 − 𝑇 𝑡 𝑇 𝑡
What's left: seasonal pattern and noise.
Detrended seasonal avg Seasonal average for all years 𝑠1, ... , 𝑠𝑀 Seasonal average for all years 𝑠1, ... , 𝑠𝑀
(March: avg of all the detrended March values)
Math part Normalize M values to make sure they add up to M Normalize M values to make sure they add up to 0
- Normalizing constant 𝑐 = 𝑀/(𝑠1 + ... + 𝑠𝑀) - Mean µ =(𝑠1 + ... + 𝑠𝑀)/M
- Seasonal index 𝑆𝑚 = 𝑐 × 𝑠𝑚, 𝑚 = 1, 2,..., 𝑀 - Seasonal index 𝑆𝑚 = 𝑠𝑚 − µ, 𝑚 = 1, 2,..., 𝑀
Seasonal component n
𝑆𝑡 = {𝑆1, 𝑆2,..., 𝑆12, 𝑆1, 𝑆2,..., 𝑆12} n
𝑆𝑡 = {𝑆1, 𝑆2,..., 𝑆12, 𝑆1, 𝑆2,..., 𝑆12}
estimation
(For monthly data, only 12 different values. )
Do the forecast
Python: from loading the data then process the raw data: converting the text to datetime data type
notcorrelated couci 0
Week4 TimeSeriesRegression o conditionalmeanEceilxito
ReviewLinear forcrosssectionaldata
Regression Homoscedasticity varies o
SimpleLinearRegressionModel agood point
starting normaldistributionassumptionnotrequiredbutit
isusefulforpredictioninterval statisticali nference
linetruepopulationmodel x botsix
true
terror makesobservationscatters random
errorassumptions
model
observation
somite notlieonthe
true line
p opulation
findBoandI withleastsquareestimation
line
regression estimationmodel
Epix minicab Eet Il BoExit Eisai e ex x
y fitted
y Iii ai te
residual observed
ei xi a
anestimateofrandomerror
Bo T Bix
ameasureofmodelaccuracy residual ei ti ti observedfitted
residualproperties
te
o and new randomerror ei y'tYi trueline
onthe
error
forecast y fi the
cyton trueline
Goodness
of fit howwellthelinearregressiontiesthedata
21 75 Recon
ofdetermination171 55 ziyi
wetlicient
er
bythemodel
theproportionofvariationexplained
Ra sawhenpredictwell R o poorlypredict
isnotreliable more p added
redictor Rat explain toowellovertie
problem
pi i hit a a
Adjusted whennos nigneradinstear ispreferred
adjustedrise equal
withregression
Forecasting assumethe dist
errorsearenorm
regression
iii
yi Botbixiitbaxai BakitEi
ThecoefficientsBmeasurethemarginalexecsonthepredictorsCarothersconstant
LinearRegressionModelfortimeseriesdata
simplelinearmodel ye botbixetet.tl it ix xe i it istimeseriesdata
Cge predictorxmightbeunknow scenariobasedforecasting predictxwith rate
growth butuncertaintyisnotincluded
Genuineforecastforx CAREHate.MGEnH
2typesofforecastdependson seminar
et
wnatisassameatobernan Expostforecast useinfobeyondtheforecastmoment
notgenuineforecast butusefulinbehaviorstudy
LinearRegressionModelfortimeseriesdata
simplelinearmodel ye botsixet et t t T Ntxe t t it istimeseriesdata
Pge predictorxmightbeunknow growthrate
scenariobasedforecasting predictxwith butuncertaintyisnotincluded
Genuineforecastforx
mmmm
eg aseasonaltimeserieswithahorizontaltrend TeBoto.ttBad BedsBudy
ta whentis atimeofseasonone da da da 0 A Bo
t2 a BoBe thewetticientsofotherseasonsmeasurethedifference inbetweenthefirstseason
owhent 7 A BotBs 8 As Bot By
modelwithLinear
Regression trend quarterlydummyvariable
ytfttbzdutbsds.ttBodyt tee diet incertainquarter ordin o
outliers usedummyvariablestoremoveoutlierseffect Isinobservation oinelsewhere
t to interventiontime
foreltectslastonlyforaperiod spikevariable xp ao otherwise
instlike foroutliers
dummy
stepvariable xe t to interventiontime
L
permanenteltece
alevelshift o t to
selectingimportantpredictors
as
gg
adjusted
spigggy tqmamiiIedigssIib inelatian errors
forecast
c caraikesInformationcriterion ate
minAec best N
nog E
observation
K
tack
predictor
andthevarianceofresiduals
intercept
numier
subsetregression oneoferor
Best It canbeused butgusted atendtoselecttoomanyvariableslesssuitableforforecasting
Residual diagnostics
plotforresidualsagainstpredictors
scatter inthemodel ifitshowsapattern nonlineari modify needed
notinthemodelifitshowsapattern addinthispredictors
7
residualagainst fittedvalues patternobserved heteroscedasticityintheerror
t
ID ay totally
ctmost
1
weighted'Éterage
most obs
recent forecasts
recent
yet tb and
Level trend
Forecastingequations
yet Elyelyne Varlyttilyc var Letbetetti yet
Eketbetettilyc p
Letbe var yeenyet 02 Ha II Chir
Tun Lethbe o ha InchDin2 crash