Data Preparation: Stationarity (Excel)

5
Data Preparation – Stationarity 1© Spider Financial Corp, 2012 Stationary Process In this issue, the second tutorial in our data preparation series, we will touch on the second most important assumption in time series analysis: Stationarity, or the assumption that a time series sample is drawn from a stationary process. We’ll start by defining the stationary process and stating the minimum stationary requirements for our time series analysis. Then we demonstrate how to examine sample data, draw a few observations, and highlight the intuitions behind them. Background In a mathematical sense, a stationary process is a stochastic process whose joint probability distribution does not change when shifted in time or space. Consequently, parameters such as the mean and variance, if they exist, also do not change as a result of a shift in time or position. This is often referred to as the strictform of stationary process. Let { } t X be a stochastic process, where 1 2 ( , ,..., ) N X t t t F x x x is the density (mass) distribution function of the joint distribution of { } t X . Then { } t X is said to be stationary if, for all values of shift ( ) and all values of 1 2 {, ,..., } N tt t , 1 2 1 2 ( , ,..., ) ( , ,..., ) N N X t t t X t t t F x x x F x x x The (.) X F function is not affected by a shift across time. A simplified example would be a Gaussian whitenoise process, where each observation is identically distributed and independent from all observations in a given sample. Consequently, the joint probability distribution of the sample data is expressed as follows: 1 2 1 2 ( , ,..., ) ( ) ( ) ... ( ) N N X t t t X t X t X t F x x x F x F x F x Furthermore, ( ) ( ) X t X t F x F x So that, 1 2 1 2 ( , ,..., ) ( , ,..., ) N N X t t t X t t t F x x x F x x x

description

In this issue, the second tutorial in our data preparation series, we will touch on the second most important assumption in time series analysis: Stationarity, or the assumption that a time series sample is drawn from a stationary process.For the example spreadsheet and tutorial video, visit us at:http://bitly.com/I4oEEM

Transcript of Data Preparation: Stationarity (Excel)

Page 1: Data Preparation: Stationarity (Excel)

 

Data Preparation – Stationarity  ‐1‐  © Spider Financial Corp, 2012  

StationaryProcessIn this issue, the second tutorial in our data preparation series, we will touch on the second most 

important assumption in time series analysis:  Stationarity, or the assumption that a time series sample 

is drawn from a stationary process. 

We’ll start by defining the stationary process and stating the minimum stationary requirements for our 

time series analysis. Then we demonstrate how to examine sample data, draw a few observations, and 

highlight the intuitions behind them.   

BackgroundIn a mathematical sense, a stationary process is a stochastic process whose joint probability distribution 

does not change when shifted in time or space. Consequently, parameters such as the mean and 

variance, if they exist, also do not change as a result of a shift in time or position. This is often referred 

to as the strict‐form of stationary process. 

Let { }tX  be a stochastic process, where 1 2

( , ,..., )NX t t tF x x x  is the density (mass) distribution function of 

the joint distribution of{ }tX . Then { }tX  is said to be stationary if, for all values of shift ( ) and all 

values of 1 2{ , ,..., }Nt t t , 

1 2 1 2( , ,..., ) ( , ,..., )

N NX t t t X t t tF x x x F x x x  

The (.)XF function is not affected by a shift across time. 

A simplified example would be a Gaussian white‐noise process, where each observation is identically 

distributed and independent from all observations in a given sample. Consequently, the joint probability 

distribution of the sample data is expressed as follows: 

1 2 1 2( , ,..., ) ( ) ( ) ... ( )

N NX t t t X t X t X tF x x x F x F x F x  

Furthermore, 

( ) ( )X t X tF x F x  

So that, 

1 2 1 2( , ,..., ) ( , ,..., )

N NX t t t X t t tF x x x F x x x  

Page 2: Data Preparation: Stationarity (Excel)

 

Data Preparation – Stationarity  ‐2‐  © Spider Financial Corp, 2012  

The stationary process assumption is very strict, and is very difficult to check for outside of a few trivial 

cases (e.g. white noise).  For practical time series analysis, a “weak‐sense” stationary process (WSS) is 

adequate.  

Weak‐sensestationary(WSS)A weaker form of stationary process is called weak‐sense stationary (WSS) or covariance stationary. The 

WSS requires that only the 1st (mean) and second (covariance) moments don’t vary with respect to 

time. 

[ ] [ ]t tE x E x  

[ ] [ ] ( )t t t t xE x x E x x m  

The WSS is also referred to as a first‐order stationary process.  Furthermore, the WSS definition leads to 

the following conclusions: 

1. That the auto‐covariance (γ ) and auto‐correlation functions (ρ ) are only dependent on  τ shiftovertime  

2. The auto covariance (γ andauto‐correlationfunctions(ρ ) are dependent on the absolute value of the shift (τ): 

   

Note: For time series analysis; we shall only concern ourselves with the WSS form of stationary process. 

CheckingforastationaryassumptionLet’s assume we have a time series data sample; how do we examine it for stationarity? 

1. VisualMethodBefore we delve into statistical tests for stationarity, let’s demonstrate in plain words how to examine 

for stationarity using a time series plot. Keep in mind that we are looking for a relatively stable mean 

and variance over time. My preferred method is to plot the sample data, moving average, and 

exponential weighted volatility on the same graph.  

The (weighted) moving average (WMA) is a proxy for the process’s marginal mean. 

The exponential‐weighted volatility (EWMA) is a proxy for the process’s marginal standard 

deviation. 

Examine the stability of the mean and variance over time.  

Example  

Page 3: Data Preparation: Stationarity (Excel)

 

Data Preparation – Stationarity  ‐3‐  © Spider Financial Corp, 2012  

Let’s look at the IBM stock daily closing prices process between January 2, 2012 and today (April 3rd, 

2012): 

 

The graph above shows a trending sample mean but rather stable volatility. As a result, the stationary 

assumption does not hold for the closing prices process. 

Note: The EWMA function assumes that the process mean is zero(0); however, this is not the case for 

the closing prices process, so we need to de‐mean the series with TSSUB before passing it to EWMA.  

Example: 

Let’s look at the daily log returns of IBM stock: 

Page 4: Data Preparation: Stationarity (Excel)

 

Data Preparation – Stationarity  ‐4‐  © Spider Financial Corp, 2012  

 

The daily log returns exhibit a stable mean over time, and the volatility is somewhat bound between 0.6 

– 1.2% per trading day.  

Note: We typically ignore the first few EWMA values because the number of observations used to 

calculate those values is very limited, leading to inaccurate results. 

Let’s look at the summary statistics table: 

 

The sample data mean is not significantly different than zero, and the volatility (standard deviation) is 

around 0.8%, which is the center line for EWMA in our sample (excluding values in the beginning of the 

sample). 

In sum, the IBM stock daily log returns data sample looks stationary. 

Page 5: Data Preparation: Stationarity (Excel)

 

Data Preparation – Stationarity  ‐5‐  © Spider Financial Corp, 2012  

2. StatisticalTestIn practice, the common reason for non‐stationarity in sample data is the presence of trend and 

integration (i.e. unit‐root) between the observations themselves. 

A number of statistical tests can be utilized to examine the stationary assumptions by decomposing the 

process into three elements: a deterministic trend, a random walk (unit‐root), and a stationary error. 

The following tests are commonly used to establish the stationary assumptions: 

(1) Trend stationary ‐ Kwiatkowski–Phillips–Schmidt–Shin (KPSS) 

(2) Unit‐root Test  or random walk test – Augmented Dickey‐Fuller (ADF) 

Thestationaryassumptionisnotholding;whatcanIdo?If a stationary assumption fails to hold, the solution it quite simple: transform the data into a stationary 

process.  

How exactly do we go about making that kind of transformation?  Earlier, we mentioned that the 

presence of trend and/or unit‐root (integration) in the time series commonly leads to non‐stationarity.  

Using the statistical test, we can check for the presence of trend and/or unit root. Next, we apply 

various techniques including de‐trending, seasonal adjustment, and differencing, in order to yield a 

stationary process. 

In financial time series, unit root (random walk) is often found in the raw time series, while trend may be 

found in macroeconomic data. An analyst’s experience and familiarity with the type of time series is 

critical in picking/applying the appropriate transformation techniques. 

In the IBM stock closing prices time series, the data showed random‐walk behavior.  We could also easily 

compute the ACF functions, and we demonstrated an ACF for lag one with a value as high as 100%. To 

remove the random‐walk, we took the first difference and ended up with a stationary process. 

IMPORTANT: We assume that the underlying process has not undergone any structural changes (i.e. 

exogenous events) within our sample data.