time series forcasting, Study notes of Data Analysis & Statistical Methods

this data science notes of time series forcasting

Typology: Study notes

2019/2020

Available from 09/26/2021

project-contact-ajay00294.at.gmail
project-contact-ajay00294.at.gmail 🇦🇺

4.7

(3)

30 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
4/4/2019
1
Disclaimer: This material is prot ected under copyright a ct AnalytixLabs ©, 2011-2016. Unauthorized use and/ or duplication of this material or any part of this material
including data, in any form without explicit and wri tten permission from AnalytixLabsis st rictly prohibited. Any violation of this copyright will attract legal actions
Time Series Analysis -
Forecasting
Introduction to Time Series Forecasting
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download time series forcasting and more Study notes Data Analysis & Statistical Methods in PDF only on Docsity!

Disclaimer: This material is protected under copyright act AnalytixLabs ©, 2011-2016. Unauthorized use and/ or duplication of this material or any part of this material including data, in any form without explicit and written permission from AnalytixLabs is strictly prohibited. Any violation of this copyright will attract legal actions

Time Series Analysis -

Forecasting

Introduction to Time Series Forecasting

▪ A time series is a set of observations generated, sequentially in time, on a single variable

▪ Time periods are of equal length (days, weeks, months, quarters, annual)

▪ Time series analysis accounts for the fact that data points taken over time may have an internal

structure (such as auto correlation, trend or seasonal variation) that should be accounted for

▪ Time series data is indexed by time and No missing values

▪ For example

  • daily stock data,
  • monthly unemployment data,
  • annual sales data
  • Macro Economic indicators Time Series Introduction Data Types

Time Series A Time Series is an ordered sequence of values of a variable observed at equally spaced time intervals. For example, monthly sales figures, daily stock prices, weekly interest rates, etc.

Cross Sectional Cross Sectional data has observations from the same time period, for different types of variables. For example, data on price, mileage, and country of origin for automobiles in India in 2005.

The success of any analysis ultimately depends on the availability of the appropriate data. It is therefore essential that we spend some time discussing the types of data that one may encounter in empirical analysis. Three types of data may be available for empirical analysis

They would typi cally ta ke the following s hape:

Statistical Forecasting

Cross-sectional data Time series data Classification of the widely used forecasting techniques Casual models Time series models Smoothing techniques Regression analysis Box-Jenkins processes Exponential and its extensions

Time Series Data - Components

Time Series data allows us to either to do analysis or forecasting.

Time series analysis comprises methods for analyzing time series data in order to extract

meaningful statistics and other characteristics of the data.

Time series forecasting is the use of a model to predict future values based on previously

observed values.

Components: Time Series can be decomposed into 4 components

▪ Trend: Trend is the gradual, long-run (or secular) evolution of the variables that we are seeking

to forecast.

▪ Seasonal Effects: Many series display a regular pattern of variability depending on the time of

year. This pattern is known as the seasonal effect.

▪ Cyclic Component: Fluctuations around the trend, excluding the irregular component,

revealing a succession of phases of expansion and contraction.

▪ Irregular Component (White Noise): The unexplained remaining variability.

Time Series Analysis – Time Series components Components of a Time Series Secular Trend: This refers to a gradual, long term movement in the data Seasonal Trend : This is the short term fluctuations in the data where the period of fluctuation is less than one year. Cyclical Movements : These are oscillatory movement in the data where the period of oscillation is typically more than a year. So, these are medium term movements. Irregular Components: These are disturbances or residual variation that remain after all the other behaviors have been accounted for. Components of a Time series are:

Forecasting Techniques Forecasting Techniques Executive Committee Delphi Technique Survey of Sales Force Survey of Customers Game Theory Judgmental Bootstrapping

ARIMA

Smoothing ARCH/GARCH Models Moving Averages Simple Linear Regression Multiple Linear Regression Neural Networks Judgmental (Qualitative) Statistical (Quantitative) Time Series Casual Time Series Techniques (1/2)

Is there any pattern?

▪ Trend (T) ▪ Seasonal index (SI) ▪ Combined trend and seasonal index (Comb) ▪ Simple Averages ▪ Moving Averages(MA) ▪ Exponential smoothing (ES) ▪ Naive

Pattern Based Pattern-less

Time Series Techniques (2/2)

How many Dependent variables?

▪ Simultaneous equation model or structural equation model ▪ VAR or VECM ▪ STATESPACE ▪ PANEL DATA MODEL,etc

Time Series Models

▪ Univariate time series model ▪ ARIMA(p,d,q), ARCH, GARCH, etc ▪ Single equation multivariate model ▪ ARIMAX(p,d,q) with ARCH, GARCH, etc Types of Time Series Techniques Pattern-less Techniques

Exponential Smoothening

Exponential s moothing is a technique that ca n be a pplied to time s eries data, either to produce smoothed data for

pres entation, or to make forecasts.

This technique i s commonly a pplied to financial market and economic data.

The s implest form of exponential smoothing is given by the formulae:

where α i s the smoothing factor, {xt} is the ra w data sequence a nd {st} is the sequence obtained after applying the

exponential s moothing algorithm.

The term exponential is used as due to back substitution we get a geometric progression which is the discrete version

of the exponential function.

There a re various forms of exponential smoothing:

Si mple Exponential Smoothing

Double Exponential Smoothing

Tri pl e Exponential Smoothing

While simple exponential smoothing requires stationary condition, the double-exponential smoothing can capture

linear trends, and tri ple-exponential smoothing can handle almost a ll other business time series (parabolic etc)

Pattern Based Technique - Decomposition Method

Seasonality ▪ Fig 1 (Passengers) displays a multiplicative seasonality with a exponentially rising trend ▪ Fig 2 (Retail Sales) displays an additive seasonality with constant mean (no linear trend) Seasonality: Many time series data follow recurring seasonal patterns. For example sales may peak around Christmas year after year. Movie ticket sales may increase noticeably on weekends. Thus, it may be useful to smooth the seasonal component independently with an extra parameter Seasonality can be Additive or Multiplicative in nature Detection: Detection of seasonality can involve plotting and visually inspecting the series, by method of indexing and also by analyzing the autocorrelogram Decomposition Models ▪ There are two types of Decomposition Models following the classical decomposition of a Time series into trend, seasonal, cyclical and irregular components

  • Additive: ▫ In the Additive model, the observed time series (Yt) is considered to be the sum of four independent components: the trend Tt the seasonal St, the cyclical Ct and the irregular It Yt = Tt + St + Ct + It
  • Multiplicative: ▫ In the Multiplicative model, the observed time series (Yt) is considered to be the product of four independent components: the trend Tt the seasonal St, the cyclical Ct and the irregular It Yt = Tt x St x Ct x It ▪ It is difficult to estimate cyclical component because of the following reasons:
  • Paucity of data in real life case studies
  • Period of oscillation is not stable, even if the data is there ▫ Hence, for short term forecasting we do not include the Cyclical component. But long term forecasts should include adjustment s for Cyclical influences

Classical Multiplicative Decomposition(3/3) Models for Time series Analysis

Models for Time Series Analysis

Models for time series data can have many forms and represent different stochastic processes.

When modeling variations in the level of a process, three broad classes of practical importance are

the autoregressive (AR) models, the integrated (I) models, and the moving average (MA) models.

These three classes depend linearly on previous data points.

Combinations of these ideas produce autoregressive moving average (ARMA) and autoregressive

integrated moving average (ARIMA) models.

There are more variations to the above mentioned models which will not be a part of the

discussion.

Stationary

Before understanding the models for Time Series, the concept of stationarity needs to grasped.

Within stationarity there are two important ideas

Strict stationarity

Second order stationarity

A sequence is strongly or strictly stationary if the sequence {xt} has the same distribution for all

sets of time points, i.e., its joint probability distribution does not change when shifted in time or

space.

where F(.) is the cumulative distribution function.

A sequence {xt} is weakly or second order stationary if the mean and the second order moments

are time invariant, i.e., independent of time.

Stationarity How to make a series stationary -- ▪ Differencing - Involves taking difference between successive values ▪ Log Transformations - makes nonconstant variance constant & removes exponential trends Why do we need to take care of Stationarity? ▪ The reason I took up this section first was that until unless your time series is stationary, you cannot build a time series model. ▪ In cases where the stationary criterion are violated, the first requisite becomes to stationarize the time series and then try stochastic models to predict this time series. ▪ There are multiple ways of bringing this stationarity. Some of them are Detrending, Differencing etc.

Auto correlation function: Autocorelate means the correlation’s between time series and the same

time series lag. It occurs when residual error terms from observations of the same variable at different

times are correlated. ACF describes the strength of the relationships between different points in the

series.

ACF While examining correlograms one should keep in mind that autocorrelations for consecutive lags are formally dependent. Consider the following example. If the first element is closely related to the second, and the second to the third, then the first element must also be somewhat related to the third one, etc. This implies that the pattern of serial dependencies can change considerably after removing the first order auto correlation (i.e., after differencing the series with a lag of 1).

Partial Auto Correlation Function: Partial autocorrelations are also correlation coefficients between

the basic time series and the same time series lag and we will eliminate the influence of the members

between

PACF Another useful method to examine serial dependencies is to examine the partial autocorrelation function (PACF) - an extension of autocorrelation, where the dependence on the intermediate elements (those within the lag) is removed. In other words the partial autocorrelation is similar to autocorrelation, except that when calculating it, the (auto) correlations with all the elements within the lag are partialled out. If a lag of 1 is specified (i.e., there are no intermediate elements within the lag), then the partial autocorrelation is equivalent to auto correlation. In a sense, the partial autocorrelation provides a "cleaner" picture of serial dependencies for individual lags (not confounded by other serial dependencies).

An augmented Dickey–Fuller test (ADF) is a test for a unit root in a time series sample. It is an

augmented version of the Dickey–Fuller test for a larger and more complicated set of time series

models.

The augmented Dickey–Fuller (ADF) statistic, used in the test, is a negative number. The more

negative it is, the stronger the rejection of the hypothesis that there is a unit root at some level of

confidence

Augment Dickey Puller Test(Unit-Root Test)

ARIMA - Three Stages EstimationEstimationEstimation Forecasting Identification Identification Here we need to check – (a) Stationarity/ Non-Stationarity (b) Seasonality (c) Order of AR and MA processes (d) White Noise Estimation To specify an ARIMA model to fit to the variable specified in the previous IDENTIFY statement and to estimate the parameters of the specified model Forecasting Forecast the future values using the model Box Jenkins Procedure The steps are

▪ Plot the time series data to check for trend and seasonality

▪ Check for stationarity

▪ Plot ACF, and PACF

▪ Make the data stationary through transformations (if needed)

▪ Plot the correlation functions and check again

▪ Identify the time series process AR, MA, or ARIMA

▪ Identify the lag

▪ Fit the ARIMA model

▪ Check the residuals

▪ Check the significance for each of the explanatory variables

▪ Drop the insignificant variables

▪ Get the final model

How does one know whether it follows a purely AR process or a purely MA process or an ARMA process or an ARIMA process, in which case we must know p, d, and q. The Box Jenkins (BJ) methodology comes in handy in answering the preceding question. The method consists of the following steps: Now the million $ question is

Box Jenkins Procedure – Summary Rules for Identifying ARIMA

Identifying the order of differencing and the constant

 If the series has positive autocorrelations out to a high number of lags, then it probably needs a higher order of differencing.  If the lag-1 autocorrelation is zero or negative, or the autocorrelations are all small and pattern less, then the series does not need a higher order of differencing. If the lag-1 autocorrelation is - 0.5 or more negative, the series may be over differenced.  The optimal order of differencing is often the order of differencing at which the standard deviation is lowest.  A model with no orders of differencing assumes that the original series is stationary (among other things, mean-reverting). A model with one order of differencing assumes that the original series has a constant average trend. A model with two orders of total differencing assumes that the original series has a time- varying trend.  A model with no orders of differencing normally includes a constant term (which represents the mean of the series). A model with two orders of total differencing normally does not include a constant term. In a model with one order of total differencing, a constant term should be included if the series has a non - zero average trend.

Box Jenkins Procedure – Summary Rules for Identifying ARIMA

Identifying the number of AR & MA terms

 If the partial autocorrelation function (PACF) of the differenced series displays a sharp cutoff and/or the lag- 1 autocorrelation is positive--i.e., if the series appears slightly "under differenced"--then consider adding one or more AR terms to the model. The lag beyond which the PACF cuts off is the indicated number of AR terms.  If the autocorrelation function (ACF) of the differenced series displays a sharp cutoff and/or the lag- 1 autocorrelation is negative--i.e., if the series appears slightly "over differenced"--then consider adding an MA term to the model. The lag beyond which the ACF cuts off is the indicated number of MA terms.  It is possible for an AR term and an MA term to cancel each other's effects, so if a mixed AR-MA model seems to fit the data, also try a model with one fewer AR term and one fewer MA term--particularly if the parameter estimates in the original model require more than 10 iterations to converge.  If there is a unit root in the AR part of the model--i.e., if the sum of the AR coefficients is almost exactly 1-- you should reduce the number of AR terms by one and increase the order of differencing by one.  If there is a unit root in the MA part of the model--i.e., if the sum of the MA coefficients is almost exactly 1-- you should reduce the number of MA terms by one and reduce the order of differencing by one.  If the long-term forecasts appear erratic or unstable, there may be a unit root in the AR or MA coefficients.