EC226-无代写
时间:2023-05-29
EC226 (Term 2: Handout 1) 1 TIME TRENDS
Introduction to Time Series and Dynamic Models
(Reading: Stock and Watson Ch 14, Dougherty Ch 11+12, Wooldridge Ch14+15).
To this point we have worked with models of the following form:
yi = β0 + β1x1i + β2x2i + ...+ βkxki + εi, for i = 1, 2 . . . n (1)
whereas we are now looking at models of the form:
yt = β0 + β1x1t + β2x2t + ...+ βkxkt + εt, for t = 1990Q1, 1990Q2 . . . (2)
This is more than a change for a subscript, i, to a subscript, t. Time series data (data collected on
a unit of observation over time) may exhibit:
1 Time trends
This reference to the ups or downs in the data across time (see Figure 1).
To get a feel for the extent of the time trend if we take lgdp=ln(gdp) and regress this on a variable
which starts at 1 and increase by 1 for each new data point, then one gets:
1
EC226 (Term 2: Handout 1) 1 TIME TRENDS
And we see from the coefficient on trend that GDP in the UK since 1980 has grown on average
by approximately 0.5% per quarter. If we take the residuals from the regression above regression and
plot this, we have a detrended series of log(real GDP) as:
The residuals show no clear trend, but there is still a lot of information in the series, in particular
about the cycle in GDP, but also the extent to which the UK economy shrank as a result of Covid-19
and the extent to which the UK economy remains below the long-run growth rate following the 2008
great recession.
2
EC226 (Term 2: Handout 1) 2 SEASONALITY
2 Seasonality
This refers to the fluctuations in the data with a regular period e.g. retail sales are generally higher
in quarter 4 (see Figure 2, which contain information on gas expenditure in the UK since 1997).
The plot clearly exhibits a trend, but also exhibits a strong quarterly pattern. If we look at the
actual data we have:
date gas
1997q1 2350
1997q2 1080
1997q3 728
1997q4 1924
1998q1 2095
1998q2 1198
1998q3 712
1998q4 1789
1999q1 2140
1999q2 1066
1999q3 583
1999q4 1828
With gas consumption increasing from Q2 to Q3 to Q4 and peaking in Q1 of each year. Imagine
treating the quarter of the year as a categorical variable with 4 outcomes: Quarter 1, Quarter 2,
Quarter 3 and Quarter 4. Then one can construct 3 dummy variables (taking, e.g. Q3 as the default)
and run the regression for lgas=ln(gas):
3
EC226 (Term 2: Handout 1) 2 SEASONALITY
Then one can see e.g. that on average Q2 consumption is bigger than Q3 consumption by
approximately 78%, Q4 consumption is above Q3 consumption by approximately 252%, and Q1
consumption is above Q3 consumption by 320%.
4
EC226 (Term 2: Handout 1) 3 LAGS AND INTERPRETING COEFFICIENTS
3 Lags and interpreting coefficients
This refers to a delay in the response between x and y as macroeconomic variables are often sluggish
to adjust to changes. This contrast with cross-sectional data where it is reasonable to assume that
the choice of individual, i, does not affect the choice of some other randomly sampled individual, j.
However, for time series data it may well be the case that information from period (t − 1) affects
outcomes in period t.
Because of this sluggishness we will often consider dynamic models, which are a generalisation of the
model specified in (2). In particular, we write the general dynamic model as:
yt = β0 + β1x1t + β2x2t + β3x1t−1 + β4x1t−2 + β5yt−1 + εt (3)
The issue with these models is on the interpretation of the coefficients. In particular what is the
effect on the variable y of a unit increase in x1. // If we (partially) differentiate yt with respect to
x1t, we get:
β1 =
dyt
dx1t
∣∣∣∣
Holding all else constant
However,
β3 ̸= dyt
dx1t−1
∣∣∣∣
Holding all else constant
as it is not possible to change x1t−1 and hold yt−1 constant (as yt−1 depends on x1t−1), as can be
seen from equation (1) lagged 1 period!
Consider, the partial derivative of equation (3) with respect to (w.r.t.) x1t, we get:
∂yt
∂x1t
= β1
∂x1t
∂x1t︸ ︷︷ ︸
1
+β2
∂x2t
∂x1t︸ ︷︷ ︸
0
+β3
∂x1t−1
∂x1t︸ ︷︷ ︸
0
+β4
∂x1t−2
∂x1t︸ ︷︷ ︸
0
+β5
∂yt−1
∂x1t︸ ︷︷ ︸
0
(4)
hence,
∂yt
∂x1t
= β1
Now consider equation (3) moved on 1 time period
yt+1 = β0 + β1x1t+1 + β2x2t+1 + β3x1t + β4x1t−1 + β5yt + εt+1 (5)
and we partially differentiate equation (5) w.r.t. x1t:
∂yt+1
∂x1t
= β1
∂x1t+1
∂x1t︸ ︷︷ ︸
0
+β2
∂x2t+1
∂x1t︸ ︷︷ ︸
0
+β3
∂x1t
∂x1t︸ ︷︷ ︸
1
+β4
∂x1t−1
∂x1t︸ ︷︷ ︸
0
+β5
∂yt
∂x1t︸ ︷︷ ︸
β1
(6)
in which case:
∂yt+1
∂x1t
= β3 + β5β1
Now consider equation (3) but written for yt+2:
yt+2 = β0 + β1x1t+2 + β2x2t+2 + β3x1t+1 + β4x1t + β5yt+1 + εt+2 (7)
5
EC226 (Term 2: Handout 1) 3 LAGS AND INTERPRETING COEFFICIENTS
and we partially differentiate equation (7) w.r.t. x1t
∂yt+2
∂x1t
= β1
∂x1t+2
∂x1t︸ ︷︷ ︸
0
+β2
∂x2t+2
∂x1t︸ ︷︷ ︸
0
+β3
∂x1t+1
∂x1t︸ ︷︷ ︸
0
+β4
∂x1t
∂x1t︸ ︷︷ ︸
1
+β5
∂yt+1
∂x1t︸ ︷︷ ︸
β3+β5β1
(8)
then
∂yt+2
∂x1t
= β4 + β5(β3 + β5β1)
Now consider equation (3) but written for yt+3:
yt+3 = β0 + β1x1t+3 + β2x2t+3 + β3x1t+2 + β4x1t+1 + β5yt+2 + εt+3 (9)
and we partially differentiate equation (9) w.r.t. x1t
∂yt+3
∂x1t
= β1
∂x1t+3
∂x1t︸ ︷︷ ︸
0
+β2
∂x2t+3
∂x1t︸ ︷︷ ︸
0
+β3
∂x1t+2
∂x1t︸ ︷︷ ︸
0
+β4
∂x1t+1
∂x1t︸ ︷︷ ︸
0
+β5
∂yt+2
∂x1t︸ ︷︷ ︸
β4+β5(β3+β5β1)
(10)
then
∂yt+3
∂x1t
= β5 [β4 + β5(β3 + β5β1)]
If we think of accumulating these responses, we get:
0 Periods Total change (contemporaneous effect) is:
∂yt
∂x1t
= β1
1 period total change is:
∂yt
∂x1t
+
∂yt+1
∂x1t
= β1 + β3 + β5β1
2 period total change is:
∂yt
∂x1t
+
∂yt+1
∂x1t
+
∂yt+2
∂x1t
= β1 + β3 + β4 + β5(β1 + β3) + β
2
5β1
3 period total change is:
∂yt
∂x1t
+
∂yt+1
∂x1t
+
∂yt+2
∂x1t
+
∂yt+3
∂x1t
= β1 + β3 + β4 + β5(β1 + β3 + β4) + β
2
5(β1 + β3) + β
3
5β1
In the long-run as x1t = x1t−1 = . . . = x1t−s = x∗1, x2t = x2t−1 = . . . = x2t−s = x

2, yt = yt−1 =
. . . = yt−s = y∗ then we have from equation (3)
y∗ = β0 + β1x∗1 + β2x

2 + β3x

1 + β4x

1 + β5y
∗ + ε∗
collecting the same variables together, we get:
y∗(1− β5) = β0 + (β1 + β3 + β4)x∗1 + β2x∗2 + ε∗
6
EC226 (Term 2: Handout 1) 3 LAGS AND INTERPRETING COEFFICIENTS
and solving for y∗
y∗ =
β0
(1− β5) +
(β1 + β3 + β4)
(1− β5) x

1 +
β2
(1− β5)x

2 (11)
In summary then we have,
Lags Multiplier
0 β1
1 β1 + β3 + β5β1
2 β1 + β3 + β4 + β5(β1 + β3) + β
2
5β1
3 β1 + β3 + β4 + β5(β1 + β3 + β4) + β
2
5(β1 + β3) + β
3
5β1
4 β1 + β3 + β4 + β5(β1 + β3 + β4) + β
2
5(β1 + β3 + β4)
+β35(β1 + β3) + β
4
5β1
5
β1 + β3 + β4 + β5(β1 + β3 + β4) + β
2
5(β1 + β3 + β4)
+β35(β1 + β3 + β4) + β
4
5(β1 + β3) + β
5
5β1
. . . . . .
∞ β1+β3+β41−β5
7
EC226 (Term 2: Handout 1) 4 MODELS WITH A LAGGED DEPENDENT VARIABLE
4 Models with a lagged dependent variable
Take the simple dynamic model:
yt = β0 + β1yt−1 + εt t = 1, . . . T (12)
and let us consider the assumptions we make in this case compared to the CLRM assumptions we
used in Term 1. In Term 1 we assumed:
1. E(εi|xi) = E(εi) = 0 (so the error term is independent of xi).
2. V (εi|xi) = σ2 (error variance is constant (homoscedastic) – points are distributed around the
true regression line with a constant spread)
3. (the errors are serially uncorrelated over observations)
4. εi|xi ∼ N(0, σ2)
Assumption 1 is a strict exogeneity assumption and implies that the errors of individual i are not
correlated with the values of the regressors for individual i and for all other individuals in the sample,
i.e. E(εi|x1, x2, ..., xn) = 0.
But in terms of equation (12) this would imply:E(εt|y1, y2, ..yt, ., yT ) = 0 and that is clearly not
sensible as from (12) cov(yt, εt) ̸= 0 and as this condition is needed for unbiasedness, then OLS
estimation of (12) yields a biased coefficient estimator (see Appendix A).
Consequently we replace assumption (1) with a weaker condition which is the condition of contempo-
raneous exogeneity, i.e. E(εt|y1, y2, ..yt−1) = 0, which implies that the errors are uncorrelated with
past values of the dependent variable.
In addition, we need to replace the assumption of random sampling in cross-sectional data (which
implies the decisions/outcomes of one person, firm, country (observation) do not impact on the out-
comes of another observation. In time series as observations are related over time, then a change in
y in 1980 is likely to have an effect on this variable in 1981. In effect this means we have a single
sequence of data. To address this we replace the assumption of Random Sampling with the conditions
of Stationarity and Weak Dependence.
Stationarity : This requires that a sequence {yt} satisfies:
1. E(yt) = µ (mean is constant at all points in time)
2. V (yt) = σ
2
y (variance is constant at all points in time)
3. cov(yt, yt−h) = γh (covariance only depend on h and not t)
Weak Dependence
This requires:
cov(yt, yt−h)→ 0 as h→∞.
We will return to these ideas in the next two handouts.
In general, if we consider any dynamic model, like:
yt = β0 + β1yt−1 + β2xt + εt t = 1, . . . T
Then if we assume:
E(εt|y1, y2, ..yt−1, xt) = 0
8
EC226 (Term 2: Handout 1) 4 MODELS WITH A LAGGED DEPENDENT VARIABLE
and given the condition of stationarity and weak dependence:
1. Our OLS estimator is not unbiased, but is consistent (implying that as the number of obser-
vations, T , gets large our OLS estimator gets “close” to the true coefficient) (see Appendix A
for a demonstration of this idea).
2. The distribution of the OLS estimator is asymptotically normally distributed (implying that as
the number of observations, T , gets large the distribution of the OLS estimator becomes like a
normal distribution). This implies for hypothesis testing of a single restriction you should use
the normal distribution NOT the t-distribution and for testing multiple restrictions you should
use the χ2-distribution rather than the F-distribution (see Appendix A for a demonstration of
this idea).
Stata commands one might use to specify the data as time series and to run a regression are briefly
covered in Appendix B.
9
EC226 (Term 2: Handout 1) A BIASES IN DYNAMIC REGRESSION MODELS
A Biases in dynamic regression models
The model:
yt = 0.5yt−1 + εt, t = 1, . . . T and εt ∼ N(0, 1)
10
EC226 (Term 2: Handout 1) B STATA COMMANDS FOR TIME SERIES MODELS
B Stata Commands for time series models
To get Stata to understand the data is time series you need to declare the data as such. So for annual
data which is of the form:
year gdp
1. 1948 325962
2. 1949 336994
3. 1950 348137
4. 1951 361238
5. 1952 367027
6. 1953 387296
7. 1954 403966
We type: tsset year
For quarterly data, which of the form:
date alc
1. 1985 Q1 3176
2. 1985 Q2 3381
3. 1985 Q3 3471
4. 1985 Q4 3800
5. 1986 Q1 3270
6. 1986 Q2 3576
7. 1986 Q3 3674
8. 1986 Q4 4078
9. 1987 Q1 3476
10. 1987 Q2 3732
We type:
generate time = quarterly(year, ”yq”)
format time
tsset time
To generate lagged value you can use:
gen lx=l.x
gen l2x=l2.x
To generate a first difference (xt − xt−1) you can use:
gen dx=d.x
To estimate a model:
yt = β0 + β1yt−1 + β2xt + β3xt−1 + εt t = 1, . . . T
By OLS one would type in Stata:
reg y l.y l(0/1).x


essay、essay代写