0% found this document useful (0 votes)
79 views77 pages

5qqmn938 - Week 1

This document provides an introduction to time series analysis concepts. It discusses topics that will be covered in the course, including transforming time series data using differences, growth rates, and charts. It also presents real-world examples of U.S. inflation and employment growth. The tutorial will demonstrate how to import, transform, chart, and run simple regressions on time series data in Stata. Finally, the document previews that autoregressive models will be covered for making forecasts of time series variables.

Uploaded by

Rammani Mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views77 pages

5qqmn938 - Week 1

This document provides an introduction to time series analysis concepts. It discusses topics that will be covered in the course, including transforming time series data using differences, growth rates, and charts. It also presents real-world examples of U.S. inflation and employment growth. The tutorial will demonstrate how to import, transform, chart, and run simple regressions on time series data in Stata. Finally, the document previews that autoregressive models will be covered for making forecasts of time series variables.

Uploaded by

Rammani Mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

Week 1: Introduction

to Time Series
Intermediate Econometrics - 5QQMN938
Dr Jack Fosten
This Week
Covered this Week
• Introducing time series using lots of real world examples of time series data
• Look at U.S. and U.K. data as well as a wider global perspective and the effects of COVID
• Time series concepts: transformations (differences, growth rates), charting, autocorrelation
• Time series regression: stationarity, outliers and outlier detection
• Real world example of U.S. CPI inflation versus employment growth

Tutorial
• Importing, transforming and charting time series in Stata, and running simple regressions
Reading
• S&W: 14 Intro, 14.1, 14.2
Looking Ahead
• We will look at the autoregressive model for making forecasts of time series variables

2 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Introducing Time
Series with U.S. Data
Let’s look at a lot of series to see what they have in
common
Introduction to Line Graphs for Time
Series Data
Time Series • Time series data charted using a line graph
• Real-time example, check out dailyfx.com
• These line graphs update constantly to track the
Time series data are those movement of USD/GBP currencies
collected at multiple points in time • The time series data for exchange rates are
available at the highest frequency
Some notation
We denote a variable 𝑌𝑡 with a time
subscript 𝑡 where:

• Observations are time periods 𝑡 =


1,2, … , 𝑇
• 𝑇 is the final data point we observe
• 𝑇 + 1, 𝑇 + 2, … are in the future
Time series data are useful for:
• Assessing predictive content of one
variable on another in a future period
• Making forecasts of the uncertain future
• Analysing financial asset prices

4 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Properties of U.S. Series pre-
2020
Let’s start to think about time series variables before 2020 (why…?)

Kick off with the United States, the largest global economy, and these important variables:

• Real Gross Domestic Product (GDP)


• Employment
• Consumer Price Index (CPI)
• Stock Prices (Dow Jones)

Think about these questions:

• What are the key features of the data?


• How would you describe the movement of the variable? Think about concepts like:
trending, not trending, flat, spiky, cyclical, seasonal, volatility clustering
• What are the units of the data? What about the frequency (monthly, quarterly etc.)

5 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Real GDP

6 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Real GDP Growth

7 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Employment

8 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Employment Growth

9 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. CPI All Items

10 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. CPI All Items Inflation

11 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Stock Prices Dow Jones

12 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Daily Stock Returns Dow
Jones

13 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Properties of U.S. Series
post-2020 with Pandemic
OK let’s stop cheating… We all know what has happened in the U.S. as a consequence of
the COVID pandemic

Now think about these questions:

• Did COVID impact the time series in a big way?


• Why/why not?
• Is this an outlier or should we treat the data seriously?
• What impact might this have on further analysis?

14 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Real GDP

15 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Real GDP Growth

16 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Employment

17 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Employment Growth

18 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. CPI All Items

19 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. CPI All Items Inflation

20 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Stock Prices Dow Jones

21 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Daily Stock Returns Dow
Jones

22 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Time Series: a wider
Perspective
Let’s have a look at more series to uncover the
properties of different time series
Wider Perspectives
Let’s dig a bit deeper into what is happening with these variables both in the U.S. and
elsewhere

1. Does U.S. real GDP look the same across all subcomponents (consumption, investment,
government spending, imports, exports)?

2. Closer to home, what has happened to the same series in the U.K.?

3. What about a global perspective? Let’s look at GDP growth in the largest economies of
each continent: China, Germany, Brazil, Nigeria, Australia

24 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Consumption Growth

25 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Consumption Growth
(Goods)

26 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Consumption Growth
(Services)

27 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Investment Growth

28 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Govt Spending Growth

29 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Exports Growth

30 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


U.S. Imports Growth

31 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


United Kingdom

32 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


United Kingdom

33 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


United Kingdom

34 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


United Kingdom

35 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Notice how the series compares

China GDP
to other GDP series

36 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


China GDP Growth Notice how the series compares
to other GDP series

37 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Germany GDP

38 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Germany GDP Growth

39 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Brazil GDP

40 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Brazil GDP Growth

41 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Nigeria GDP

42 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Nigeria GDP Growth

43 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Australia GDP

44 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Australia GDP Growth

45 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Time Series
Concepts
Properties of time series, transformations, charting
and using Stata
Properties of Time Series
Always be sure to look at the Look how different all of these series
definitions of the data are. We’ll study all types of time series
Definitions of Time Series Concepts in Time Series
• Start and end dates • Outliers
• Frequency (between periods 𝑡 and 𝑡 + 1) • Stationarity (we will cover later)
– Annual/quarterly/monthly/daily? – “Flat”, noisy, roughly constant series
• Transformations and scale • Non-stationarity
– Levels, growth rates, thousands vs. – Trends, cycles, “random walk”
millions, index numbers (2000=100), • Volatility
real vs. nominal, seasonally adjusted • Seasonality
– Winter effects, “Monday effect”
• Structural breaks (jumps)

47 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Time Series Data Stata Commands
in Stata Import the data, which in this example
includes a variable called “Date” which is an
Excel-formatted date variable

Can also import via File/Import/Excel…


We always have to tell Stata that
we are using time series data import excel
"C:\.........\GDP.xls",
using the command “tsset” sheet("data") firstrow
• Usually we import a date variable from the
xls/csv file from Excel With quarterly data:
• We then need to convert it to a Stata date generate date_q=qofd(Date)
number for quarter/month format date_q %tq
tsset date_q
• Then format it correctly
• Then set it as the time series variable With monthly data:
using “tsset” generate date_m=mofd(Date)
• We will practice this in the tutorial format date_m %tm
tsset date_m

48 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Time Series Stata Commands
Transformations We can generate (“gen”) the following
variables (if we have a variable “y”)

1) Lags use L1. L2. L3. etc.


gen lagy=L1.y
Lags gen lag2y=L2.y
• The lag of 𝑌𝑡 is 𝑌𝑡−1 , the observation in
the previous period 2) Logs
gen logy=log(y)
• The second lag is 𝑌𝑡−2 and so on
• We use lags to model dynamics, and to 3) Differences use D.
gen diffy=D.y
estimate dynamic (causal) effects
Differences 4) Growth rate combines the two:
gen dy=log(y)-log(L1.y)
• Δ𝑌𝑡 = 𝑌𝑡 − 𝑌𝑡−1
• We will see why these are used later
Growth rate (difference in logs)
Logs
• For small changes, Δ ln 𝑌𝑡 = (ln 𝑌𝑡 −
• We often use the natural logarithm - ln 𝑌𝑡 -
ln 𝑌𝑡−1 ) gives the decimal growth rate
for monetary variables, or variables with
between periods 𝑡 − 1 and 𝑡
exponential trends
• 100Δ ln 𝑌𝑡 = 100(ln 𝑌𝑡 − ln 𝑌𝑡−1 ) gives the
% growth rate

49 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Charting Time Stata Commands
Series in Stata
Basic line graph (see below) :
tsline y, ytitle(Level of y)
xtitle(Time) title(Plot of y)

We will practice charting in the Nicer graphs use package called “blindschemes”
and a scheme called plottig
next tutorial
ssc install blindschemes, replace
• The line graph is the most common TS
chart tsline y, ytitle(“Level of y")
xtitle(Time) title(Plot of y)
• In Stata you can access all graphing on scheme(plottig)
the menu Graphics->Twoway graph ->
Create
• Once you have done this, you will see the
code appear and you can edit it using
various options for titles

50 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Measuring Time Stata Commands
Series Correlation
Sample covariance between 𝑌𝑡 with 𝑌𝑡−𝑗 is calculated as:
𝑇
1
𝑐𝑜𝑣 ෣
𝑌𝑡 , 𝑌𝑡−𝑗 = ෍ (𝑌𝑡 − 𝑌ത𝑗+1:𝑇 )(𝑌𝑡−𝑗 − 𝑌ത1:𝑇−𝑗 )
𝑇
𝑡=𝑗+1

• Autocorrelation, or “serial correlation” Can only sum from 𝑗 + 1 to 𝑇 as data starts from 𝑡 = 1

measured by covariance of 𝑌𝑡 with 𝑌𝑡−𝑗 The autocorrelation is:

• The 𝑗th autocovariance is: 𝑐𝑜𝑣 ෣


𝑌𝑡 , 𝑌𝑡−𝑗
𝜌ො𝑗 =

𝑣𝑎𝑟 𝑌𝑡
𝑐𝑜𝑣(𝑌𝑡 , 𝑌𝑡−𝑗 )
In Stata the command is “ac” followed by the variable name
• The 𝑗th autocorrelation is:
𝑐𝑜𝑣(𝑌𝑡 , 𝑌𝑡−𝑗 ) Confidence bands show that only the
𝜌𝑗 = 𝑐𝑜𝑟𝑟 𝑌𝑡 , 𝑌𝑡−𝑗 = 1st and 2nd ACs are significant
𝑣𝑎𝑟 𝑌𝑡 𝑣𝑎𝑟(𝑌𝑡−𝑗 )
• Positive autocorrelation (see right) – if
𝑌𝑡 larger than average in 𝑡 then it tends to
be larger than average in 𝑡 + 1
• Negative autocorrelation is rare in
standard economic series
• Confidence interval: is autocorrelation
significantly different from zero?

51 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Time Series
Regression and
Stationarity
The assumptions required for running time series
regressions
Do we care about beta?
The Basic Time
Series Regression In the Introduction to Econometrics you saw how to
estimate 𝛽 coefficients consistently by OLS.

Often in time series we care more about forecasts


Let’s take two variables 𝑌𝑡 and 𝑋𝑡 : (predictions) of 𝑦𝑡 and not the individual
coefficients. For example, in the 2-variable model:
Simple Regression Model
𝑌𝑡 = 𝛽0 + 𝛽1 𝑋1𝑡 + 𝛽2 𝑋2𝑡 + 𝑢𝑡
𝑌𝑡 = 𝛽0 + 𝛽1 𝑋𝑡 + 𝑢𝑡 (1) We might be more worried about the prediction:
Simple Regression Model with lagged 𝑿𝒕 𝑌෠𝑡 = 𝛽መ0 + 𝛽መ1 𝑋1𝑡 + 𝛽መ2 𝑋2𝑡
𝑌𝑡 = 𝛽0 + 𝛽1 𝑋𝑡−1 + 𝑢𝑡 (2)
And not care too much about whether 𝛽መ1 and 𝛽መ2 are
where 𝑢𝑡 is the regression error term. ‘good’ estimates of 𝛽1 and 𝛽2 . However, these
might be important for policy decisions.
• The coefficient 𝛽1 measures the change in 𝑌𝑡
following:
– a 1 unit change in 𝑋𝑡 in the same time period (1)
or:
– a 1 unit change in 𝑋𝑡 in the previous period (2)
• We will analyse models like this later in the course

53 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


The Basic Time OLS Recap
Series Regression
The Ordinary Least Squares (OLS) estimates 𝛽መ0 and 𝛽መ1 by
minimising the sum of squared residuals:
𝑇
2
෍ 𝑌𝑡 − 𝛽0 − 𝛽1 𝑋𝑡

Simple Regression Model


𝑡=1

With respect to 𝛽0 and 𝛽1 . This gives estimators 𝛽መ0 and 𝛽መ1


𝑌𝑡 = 𝛽0 + 𝛽1 𝑋𝑡 + 𝑢𝑡 and the residuals:

𝑢ො 𝑡 = 𝑌𝑡 − 𝛽መ0 − 𝛽መ1 𝑋𝑡

The classical standard errors (like those calculated


• We estimate 𝛽෠0 and 𝛽෠1 by OLS automatically by Stata) are only valid under
homoskedasticity and no autocorrelation of the error
• 𝛽෠0 and 𝛽෠1 are consistent for 𝛽0 and 𝛽1 term
under assumptions 1 to 4 (S&W 15.3)
• Specific to time series analysis:
Assumptions (S&W 15.3)
– We need stationarity
The basic bivariate time series regression requires the
– We need no large outliers following assumptions:
1. 𝑋 is exogenous, that is, 𝐸(𝑢𝑡 |𝑋𝑡 , 𝑋𝑡−1 , 𝑋𝑡−2 , …)=0
– We will come back to exogeneity later
2. (a) The random variables 𝑌𝑡 and 𝑋𝑡 have a stationary
• The classical standard errors require no distribution (b) (𝑌𝑡 , 𝑋𝑡 ) and (𝑌𝑡−𝑗 , 𝑋𝑡−𝑗 ) become
independent as 𝑗 gets large
autocorrelation and homoskedasticity
3. Large outliers are unlikely: 𝑌𝑡 and 𝑋𝑡 have more than
• Otherwise we need robust standard eight nonzero, finite moments, and
4. There is no perfect multicollinearity
errors

54 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Stationary Time Series
Strict stationarity of 𝑦𝑡 means its Weak stationarity of 𝑦𝑡 means the
distribution does not change over first two moments (mean, variance
time and covariance) do not change
Strict Stationarity Weak Stationarity
A series 𝑌𝑡 is strictly stationary if the joint A series 𝑌𝑡 with 𝑣𝑎𝑟 𝑌𝑡 < ∞ is weakly
distribution of (𝑌𝑠+1 , 𝑌𝑠+2 , … , 𝑌𝑠+𝑇 ) does not stationary if (i) 𝐸(𝑌𝑡 ) is constant, (ii) 𝑣𝑎𝑟(𝑌𝑡 )
depend on 𝑠, regardless of 𝑇. is constant and (iii) 𝑐𝑜𝑣 𝑌𝑡 , 𝑌𝑡+𝑗 only
• Otherwise the series is said to be non- depends on 𝑗 and not 𝑡.
stationary • Weak stationarity is also known as
• Strict stationarity is sometimes called “covariance stationarity”
“strong stationarity” • Often the two definitions are equivalent,
so we will use weak stationarity in
this course

55 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Example of a
Stationary Time Series
Process
The white noise process is probably
the simplest stationary process
• You might have heard of a “white noise”
process
• A white noise 𝑌𝑡 process has:
i. 𝐸 𝑌𝑡 = 0 (zero mean)
ii. 𝑣𝑎𝑟 𝑌𝑡 = 𝜎 2 (constant variance)
iii. 𝑐𝑜𝑣 𝑌𝑡 , 𝑌𝑡+𝑗 = 0 (no autocorrelation)
• It is therefore weakly stationary
• This graph is an iid white noise sequence
drawn from a 𝑁 0,1 distribution
• We will focus on stationary time series in
the first half of the course

56 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


What might a non-stationary
variable look like?
• If this white noise process is stationary, how
might a variable be non-stationary?

57 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Which of the series
from before are
stationary?
Let’s revisit the graphs we saw
before
Stationary vs Non-stationary?
• All of the trending variables cannot be
stationary
• Many economic series are non-stationary
but their growth rates are stationary
• We will cover all of these cases in the
course

58 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


The AC as an
“Informal” Check of
Stationarity
• Informally check a series being stationary
by looking at the autocorrelations
• If the ACs are fairly low and die quickly to
zero, it is likely to be stationary
• If the AC starts close to one and slowly ACF for U.S. real GDP before 2020 (above) and real
GDP growth before 2020 (below)
declines, it is likely to be nonstationary
• Later in the course we will look at a formal
statistical test for stationarity
• In the meantime, we will use the growth
rates or differences of most time series

59 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Outlier Detection
• Outliers are also a problem for regressions
• How do we detect outliers?
1. We can simply “eyeball” the data to see which observations look out of place
2. Use a formal detection method. The FRED-MD database of McCracken and Ng
suggests 𝑌𝑡 is an outlier when:
𝑌𝑡 − 𝑚𝑒𝑑𝑖𝑎𝑛 𝑌 > 10 ∗ 𝐼𝑄𝑅(𝑌)
i.e. if the distance of 𝑌𝑡 from the median is more than 10x the interquartile range

• What to do with outliers?


1. Check for mistakes in the data entry (have we used millions instead of billions?)
2. If correct, it’s best to report results with and without the outliers (be honest!) and show
how it affects the results (e.g. plots, autocorrelations, regressions)
3. To run results without the outlier, either drop it from the dataset or create a dummy
variable for that observation

60 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Outlier Detection

• Here we see an outlier in variable x at


observation 𝑡 = 100
• If we run a regression this will clearly bias
the results. Let’s look at both.
• We can use summary x, detail in
Stata to get the median and IQR
• These are median(x)=1.55 and IQR=2.90-
0.41=2.49
• This observation is not quite large enough
to be detected by the formal rule above

61 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Regression with Outlier
. reg y x, robust

Linear regression Number of obs = 200


F(1, 198) = 2.08
Prob > F = 0.1509
R-squared = 0.1188
Root MSE = 1.0459

------------------------------------------------------------------------------
| Robust
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | .1557925 .1080369 1.44 0.151 -.0572582 .3688433
_cons | 1.44982 .1687845 8.59 0.000 1.116974 1.782666
------------------------------------------------------------------------------

62 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Regression without Outlier
. gen outlier=0

. replace outlier=1 if t==100


(1 real change made)

. reg y x outlier, robust

Linear regression Number of obs = 200


F(1, 197) = .
Prob > F = .
R-squared = 0.3399
Root MSE = .90755

------------------------------------------------------------------------------
| Robust
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | .3495791 .0328697 10.64 0.000 .2847573 .4144008
outlier | -10.00234 .7794427 -12.83 0.000 -11.53946 -8.465214
_cons | 1.174125 .0783479 14.99 0.000 1.019617 1.328633
------------------------------------------------------------------------------

.
63 KING’S BUSINESS SCHOOL | kcl.ac.uk/business
Regression without Outlier
. reg y x if t!=100, robust

Linear regression Number of obs = 199


F(1, 197) = 113.68
Prob > F = 0.0000
R-squared = 0.3311
Root MSE = .90755

------------------------------------------------------------------------------
| Robust
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | .3495791 .0327875 10.66 0.000 .2849196 .4142385
_cons | 1.174125 .0781518 15.02 0.000 1.020003 1.328246
------------------------------------------------------------------------------

64 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Real World Case
Study
Simple time series regression of U.S. CPI inflation on
employment growth
U.S. CPI Inflation vs.
Employment Growth

Equation:
Δ ln 𝐶𝑃𝐼𝑡 = 𝛽0 + 𝛽1 Δ ln 𝐸𝑚𝑝𝑡 + 𝑢𝑡
• This is related to Phillips curve which
relates inflation to unemployment
• Remember the issues with employment
growth outliers. We will look at this now
• Do these look stationary? Do they fulfil
the assumptions?
• What are the drawbacks of this
equation?
• Can we forecast using this equation?

66 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


CPI Autocorrelation

67 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


CPI Inflation Autocorrelation

68 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Employment Autocorrelation

69 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Employment Growth
Autocorrelation

This is
VERY
weird and
likely
caused by
the
pandemic
periods

70 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Employment Growth Outlier
Detection
. sum dEmp, detail

dEmp
-------------------------------------------------------------
Percentiles Smallest
1% -.6119031 -15.45299
5% -.2991179 -2.077889
10% -.1914789 -.8524818 Obs 466
25% -.0366181 -.6608913 Sum of wgt. 466

50% .1240015 Mean .0920358


Largest Std. dev. .8062696
75% .2479633 1.502157
90% .3927385 2.371348 Variance .6500706
95% .5169734 2.855626 Skewness -15.13446
99% 1.446434 3.605258 Kurtosis 299.1995

. gen med= .1240015

. gen distance=abs(dEmp-med)

. gen outlier=0
. replace outlier=1 if distance>10*(.2479633 +.0366181)

71 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Employment Growth
Autocorrelation without Outliers

This looks
much
more like
a regular
stationary
time series

72 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Inflation vs Employment
Growth (with outliers)
– Regression with robust standard errors
– Employment changes are positively related to CPI inflation and significant at 1% level
– May be worried about autocorrelation of the error term. Don’t worry, we’ll address this later
in the course!
. reg dCPI dEmp, robust

Linear regression Number of obs = 466


F(1, 464) = 49.50
Prob > F = 0.0000
R-squared = 0.0503
Root MSE = .263

------------------------------------------------------------------------------
| Robust
dCPI | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
dEmp | .0749521 .010653 7.04 0.000 .054018 .0958862
_cons | .2232114 .0123352 18.10 0.000 .1989717 .2474511
------------------------------------------------------------------------------

N.B. dEmp is significant at the 1% level as the p-value<0.01. Alternatively, using the t-statistic, since |t|>z0.01 where z0.01=2.58

73 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Inflation vs Employment
Growth (without outliers)
– We now remove the outliers using if outlier==0
– The outlier has had a reasonable impact on the coefficient, and the significance (now only
significant at 5% level)

. reg dCPI dEmp if outlier==0, robust

Linear regression Number of obs = 464


F(1, 462) = 4.47
Prob > F = 0.0351
R-squared = 0.0201
Root MSE = .26316

------------------------------------------------------------------------------
| Robust
dCPI | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
dEmp | .1168101 .0552788 2.11 0.035 .008181 .2254391
_cons | .2179885 .0146456 14.88 0.000 .1892082 .2467687
------------------------------------------------------------------------------

74 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Take-aways
What did we learn? Where are we going next?
What have we done this
week?
Re-cap
• We have seen how time series variables can be very different
• You might see trends, cycles, seasonality, volatility etc. in time series data
• We learnt about lags, differences and autocorrelations
• We saw how stationarity is required in time series regression and the
definitions of strict and weak stationarity, as well as outlier detection
• We looked at how to do everything in Stata, with an example of CPI inflation
and employment growth

Next Time
• We will look at the autoregressive model for making forecasts
• We will make an actual forecast for CPI inflation!

76 KING’S BUSINESS SCHOOL | kcl.ac.uk/business


Thank you
Thanks for your attention this week!

You might also like