Time Series introduction in R - Iñaki Puigdollers

Slides:



Advertisements
Similar presentations
FINANCIAL TIME-SERIES ECONOMETRICS SUN LIJIAN Feb 23,2001.
Advertisements

Autocorrelation Functions and ARIMA Modelling
Forecasting Using the Simple Linear Regression Model and Correlation
Part II – TIME SERIES ANALYSIS C5 ARIMA (Box-Jenkins) Models
Model specification (identification) We already know about the sample autocorrelation function (SAC): Properties: Not unbiased (since a ratio between two.
Slide 1 DSCI 5340: Predictive Modeling and Business Forecasting Spring 2013 – Dr. Nick Evangelopoulos Lecture 7: Box-Jenkins Models – Part II (Ch. 9) Material.
Time Series Building 1. Model Identification
R. Werner Solar Terrestrial Influences Institute - BAS Time Series Analysis by means of inference statistical methods.
STAT 497 APPLIED TIME SERIES ANALYSIS
13 Introduction toTime-Series Analysis. What is in this Chapter? This chapter discusses –the basic time-series models: autoregressive (AR) and moving.
Forecasting JY Le Boudec 1. Contents 1.What is forecasting ? 2.Linear Regression 3.Avoiding Overfitting 4.Differencing 5.ARMA models 6.Sparse ARMA models.
Modeling Cycles By ARMA
Prediction and model selection
ARIMA Forecasting Lecture 7 and 8 - March 14-16, 2011
Financial Econometrics
Modern methods The classical approach: MethodProsCons Time series regression Easy to implement Fairly easy to interpret Covariates may be added (normalization)
Statistics 350 Lecture 17. Today Last Day: Introduction to Multiple Linear Regression Model Today: More Chapter 6.
1 Simple Linear Regression 1. review of least squares procedure 2. inference for least squares lines.
BOX JENKINS METHODOLOGY
STAT 497 LECTURE NOTES 2.
1 Least squares procedure Inference for least squares lines Simple Linear Regression.
What does it mean? The variance of the error term is not constant
STAT 497 LECTURE NOTES 4 MODEL INDETIFICATION AND NON- STATIONARY TIME SERIES MODELS 1.
Autoregressive Integrated Moving Average (ARIMA) Popularly known as the Box-Jenkins methodology.
John G. Zhang, Ph.D. Harper College
Introducing ITSM 2000 By: Amir Heshmaty Far. S EVERAL FUNCTION IN ITSM to analyze and display the properties of time series data to compute and display.
Big Data at Home Depot KSU – Big Data Survey Course Steve Einbender Advanced Analytics Architect.
Week 21 Stochastic Process - Introduction Stochastic processes are processes that proceed randomly in time. Rather than consider fixed random variables.
Time Series Basics Fin250f: Lecture 8.1 Spring 2010 Reading: Brooks, chapter
Time Series Analysis Lecture 11
EC208 – Introductory Econometrics. Topic: Spurious/Nonsense Regressions (as part of chapter on Dynamic Models)
Review and Summary Box-Jenkins models Stationary Time series AR(p), MA(q), ARMA(p,q)
The Box-Jenkins (ARIMA) Methodology
Ch16: Time Series 24 Nov 2011 BUSI275 Dr. Sean Ho HW8 due tonight Please download: 22-TheFed.xls 22-TheFed.xls.
Introduction to stochastic processes
Time Series Analysis PART II. Econometric Forecasting Forecasting is an important part of econometric analysis, for some people probably the most important.
Subodh Kant. Auto-Regressive Integrated Moving Average Also known as Box-Jenkins methodology A type of linear model Capable of representing stationary.
EC 827 Module 2 Forecasting a Single Variable from its own History.
Review of Unit Root Testing D. A. Dickey North Carolina State University (Previously presented at Purdue Econ Dept.)
Forecasting. Model with indicator variables The choice of a forecasting technique depends on the components identified in the time series. The techniques.
1 Autocorrelation in Time Series data KNN Ch. 12 (pp )
Analysis of Financial Data Spring 2012 Lecture 4: Time Series Models - 1 Priyantha Wijayatunga Department of Statistics, Umeå University
Lecture 9 Forecasting. Introduction to Forecasting * * * * * * * * o o o o o o o o Model 1Model 2 Which model performs better? There are many forecasting.
Time Series Analysis By Tyler Moore.
Stochastic Process - Introduction
Multiple Random Variables and Joint Distributions
Covariance, stationarity & some useful operators
Regression Analysis AGEC 784.
Case study 4: Multiplicative Seasonal ARIMA Model
Dynamic Models, Autocorrelation and Forecasting
Linear Regression.
Nonstationary Time Series Data and Cointegration
Financial Econometrics Lecture Notes 2
Lecture 9 Time Series Econometrics: Some Basic Ideas
Ch8 Time Series Modeling
Lecture 8 ARIMA Forecasting II
Applied Econometric Time Series Third Edition
Chapter 6: Autoregressive Integrated Moving Average (ARIMA) Models
Applied Econometric Time-Series Data Analysis
BA 275 Quantitative Business Methods
Stock Prediction with ARIMA
Introduction to Time Series
Understanding Nonstationarity and Recognizing it When You See it
Chapter 8 Supplement Forecasting.
Chapter 13 Additional Topics in Regression Analysis
Lecturer Dr. Veronika Alhanaqtah
CH2 Time series.
BOX JENKINS (ARIMA) METHODOLOGY
Chap 7: Seasonal ARIMA Models
Presentation transcript:

Time Series introduction in R - Iñaki Puigdollers 10th of March 2016

Quick Overview A time series is: Sequence of observations TIME SERIES MODELLING AND FORECASTING Quick Overview A time series is: Sequence of observations Generated from a stochastic process (random variables) Ordered in time Model a time series: find a mathematical expression for a time series Time series forecasting: use a model to predict its future values Examples of models: Linear Regression SARIMA

Quick Overview A time series is: Sequence of observations TIME SERIES MODELLING AND FORECASTING Quick Overview A time series is: Sequence of observations Generated from a stochastic process (random variables) Ordered in time Model a time series: find a mathematical expression for a time series Time series forecasting: use a model to predict its future values Examples of models: Linear Regression SARIMA

Linear regression Simple linear regression Dependent/Response variable TIME SERIES MODELLING AND FORECASTING Linear regression Simple linear regression Dependent/Response variable Regression coefficient Independent variable or regressor Error term

Linear regression Multiple linear regression TIME SERIES MODELLING AND FORECASTING Linear regression Multiple linear regression Smaller n’s are preferable (parsimony principle, a.k.a. Occam’s razor)

Linear regression Assumptions: TIME SERIES MODELLING AND FORECASTING Linear regression Assumptions: Linear relation between Y and X (in case of multiple linear regression with each Xi) In multiple linear regression, the regressors (Xi) are pairwise independent The errors (𝜀t) are gaussian white noise: independent and normally distributed

SARIMA (Seasonal Autoregressive Integrated moving Average) TIME SERIES MODELLING AND FORECASTING SARIMA (Seasonal Autoregressive Integrated moving Average) SARIMA (p,d,q)x(P,D,Q)s: Season Period (12 for a year, 7 for a week, …) COMPONENTS: Non-seasonal Seasonal TERMS: Autoregressive Error Moving average Autoregressive Moving average

TIME SERIES MODELLING AND FORECASTING SARIMA Assumptions: Weak (2nd order) stationarity*: the time series behaviour is not varying over time Errors are gaussian white noise: independent and normally distributed *Stationarity: A time series is called stationary if all their moments are constant over time A time series is called 2nd order stationary if the mean (1st order moment) and variance (2nd order moment) are constant over time

Box & Jenkins Methodology TIME SERIES MODELLING AND FORECASTING Box & Jenkins Methodology A methodology to model SARIMA time series The methodology is composed by 3 different stages: Model selection Parameters estimation Model Checking

B&J: Model Selection Detect stationarity TIME SERIES MODELLING AND FORECASTING B&J: Model Selection Detect stationarity To detect mean-sationarity: use stationarity tests like Kiwatowski-Phillips-Schmidt-Shin (KPSS) or Augmented Dickey-Fuller (ADF) or Autocorrelation function (ACF) or by simply looking at the plot of the data Quite often you can make a time series stationary by applying a difference filter of order , i.e. to every point Xt in the time series apply the following transformation: Yt = Xt – Xt-1 To detect variance stationarity: use Priestly-Suba-Rao test (PSR) or the ACF, or looking at the plot of the data You can try to achieve stationarity in variance by applying the Box-Cox transformation to the series (for positive time series) or Yeo-Johnson transformation (for non-positive time series). Please check the appendix for the closed-for formulae. Remember: If you can’t make the time series stationary, it can’t be modelled as a SARIMA!!!!

Stationarity? Stationary time series Non-Stationary time series TIME SERIES MODELLING AND FORECASTING Stationarity? Stationary time series Non-Stationary time series

B&J: Model Selection Detect seasonality TIME SERIES MODELLING AND FORECASTING B&J: Model Selection Detect seasonality Use ACF and partial autocorrelation function (PACF) to detect if there is any seasonal pattern If there is seasonality you have to seasonal-difference the time series before modelling it, i.e. difference the time series S times (where S is the order of the seasonality, e.g. if we have monthly data and the seasonality is quarterly you have to apply a order 4 difference filter. See appendix for a closed-for formula.

Seasonality? Seasonal time series Non-seasonal time series TIME SERIES MODELLING AND FORECASTING Seasonality? Seasonal time series Non-seasonal time series

EXPONENTIALLY DECREASES TIME SERIES MODELLING AND FORECASTING B&J: Model Selection Identify the parameters p & q (same for P & Q but at seasonal level) EXPONENTIALLY DECREASES

B&J: Parameter Estimation TIME SERIES MODELLING AND FORECASTING B&J: Parameter Estimation Most common practice is to use numerical methods to estimate the parameters by finding the most likelihood estimator. In order to asses which parameter is best fitting the most common practice is minimizing some information criteria, either: Akaike information criterion (AIC) Akaike information criterion corrected (AICc), this one tends to be preferred as it is not dependent on the size of the sample Bayesian information criterion (BIC)

TIME SERIES MODELLING AND FORECASTING B&J: Model Checking Once the model is built we need to make sure that the errors of the model are gaussian distributed (i.e. they are white noise). If they are not, this means that the the errors may have a SARIMA structure itself, so the most common practice is to apply the same methodology (Box-Jenkins)again to the errors of the series In order to assess the normality of the errors you can use among other Ljung-Box normality test (LB) or Durbin-Watson (DW), but you can also check it by plotting the ACF/PACF of the errors (if they are normal all the values of the ACF/PACF will be inside the confidence interval)

TIME SERIES MODELLING AND FORECASTING DEMO TIME !!!

TIME SERIES MODELLING AND FORECASTING Appendix Box-Cox transformation (for trying to make non-variance-stationary POSITIVE time series into variance-stationary time series)

TIME SERIES MODELLING AND FORECASTING Appendix Yeo-Johnson transformation (for trying to make non-variance-stationary time series into variance-stationary time series)

Appendix The difference filter TIME SERIES MODELLING AND FORECASTING Appendix The difference filter The difference operator (or order 1 difference filter) is In general an order r difference filter can be calculated recursively as a sequence of difference operators