# Error Correction

Cointegration is a relationship between two nonstationary, I(1), variables. These variables share a common trend and tend to move together in the long-run. In this section, a dynamic relationship between I(0) variables that embeds a cointegrating relationship known as the short-run error correction model is examined.

yt = S + dryt-i + 5oXt + Sixt-i + vt (12.7)

after some manipulation (see POE4 for details)

Ayt = -(1 – di)(yt-i – ві – foxt-1) + SoAxt + SiAxt-i + vt (12.8)

The term in the second set of parentheses is a cointegrating relationship. The levels of y and x are linearly related. Let a = (1 — 91) and the equation’s parameters can be estimated by nonlinear least squares.

In gretl this is easiest done in a script. There are basically three steps. First open the data and create lags and differences. Second, decide upon reasonable starting values for the numerical optimization procedure. Finally, specify the equation to be estimated by nls.

1 open "@gretldirdatapoeusa. gdt"

2 lags 2; f b

3 diff f b

4 ols b const f

5 scalar b1 = \$coeff(const)

6 scalar b2 = \$coeff(f)

7 ols d_b const d_f(0 to -1)

8 scalar d0 = \$coeff(d_f)

9 scalar d1 = \$coeff(d_f_1)

10 ols b const b(-1) f(0 to -1)

11 scalar a = 1-\$coeff(b_1)

12 nls d_b=-a*(b_1-b1-b2*f_1)+d0*d_f+d1*d_f(-1)

13 params a b1 b2 d0 d1

14 end nls

The hardest part of this is giving the routine a decent set of starting values. Here, I used three separate linear regressions to generate reasonable starting values. I estimated the cointegrating relationship via least squares in line 4 to populate ві and в2. To get start values for £0 and ^ I used a similar strategy, estimating the ARDL(1,1) in its difference form (equation 12.8). Estimate that regression without the cointegrating relationship in it and use these parameters as the starting values. For the parameter a, I estimated equation (12.7) and used a0 = (1 — 0).

Since I am reluctant to taking derivatives analytically unless I have to, I tried to estimate the model without them, relying on gretl’s excellent numerical versions. The params statement in line 13 is required when using numerical derivatives. Fortunately, gretl rewarded me with the correct result (as verified in Eviews and Stata).

Using numerical derivatives

Tolerance = 1.81899e-012

Convergence achieved after 19 iterations

NLS, using observations 1984:3-2009:4 (T = 102) d_b = -a*(b_1-b1-b2*f_1)+d0*d_f+d1*d_f(-1)

estimate std. error t-ratio p-value

a 0.141877 0.0496561 2.857 0.0052 ***

b1 1.42919 0.624625 2.288 0.0243 **

 b2 0.776557 0.122475 6.341 7.25e-09 *** d0 0.842463 0.0897482 9.387 2.83e-15 *** d1 -0.326845 0.0847928 -3.855 0.0002 ***

Once the model is estimated, you can get the implied estimate of 9.

scalar theta1 = 1-\$coeff(a)

which is 0.858123. You can also perform an EG test for stantionarity by constructing the residuals and using adf. In this case, you’ll have to consult a table of critical values since the EG ones are not available from adf routine.

series ehat = b-\$coeff(b1)-\$coeff(b2)*f adf 1 ehat –nc

As before, the null is that (b, f) are not cointegrated. Since the cointegrating relationship includes a constant term, the critical value is (-3.37). Comparing the calculated value -3.92668 with the critical value, we reject the null hypothesis and conclude that (b, f) are cointegrated.

12.1 Script

1 open "@gretldirdatapoeusa. gdt"

2 set echo off

3 # take differences

4 diff b inf f gdp

5 # change variable attributes

6 setinfo b – d "3-year Bond rate" – n "3-year Bond rate"

7 setinfo d_b – d "Change in the 3-year Bond rate" – n "D. BOND"

8 setinfo inf – d "annual inflation rate" – n "inflation rate"

9 setinfo d_inf – d "Change in the annual inflation rate" – n "D. INFLATION"

10 setinfo gdp – d "real US gross domestic product" – n "Real GDP"

11 setinfo d_gdp – d "= first difference of gdp" – n "D. GDP"

12 setinfo f – d "federal funds rate" – n "Fed Funds Rate"

13 setinfo d_f – d "= first difference of f" – n "D. FED_FUNDS"

 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

# multiple time series plots scatters inf d_inf f d_f scatters b d_b gdp d_gdp

# summary statistics for subsamples and full sample smpl 1984:2 1996:4

summary —simple smpl 1997:1 2009:4 summary –simple smpl full

list levels = gdp inf f b summary levels –simple

# spurious regression

open "@gretldirdatapoespurious. gdt" setobs 1 1 –special-time-series gnuplot rw1 rw2 —with-lines —time-series ols rw1 rw2 const

open "@gretldirdatapoeusa. gdt" adf 4 f –c –ct –test-down adf 4 b –c –test-down –verbose

function scalar modelseladf (scalar p, series *y) diff y

matrix A = {}

loop i = 1..p —quiet

list vars = d_y(0 to – i) y(-1) const matrix a = i~modelsel2(vars) matrix A = A | a endloop

colnames(A,"p K N AIC SC ") print A return 0 end function

smpl full

scalar mlag = int(12*((\$nobs+1)/100)rt(0.25)) adf mlag f —ct —gls —test-down adf mlag b —ct —gls —test-down

# kpss test kpss 0 f b

coint 4 f b inf —test-down —skip-df

open "@gretldirdatapoeusa. gdt" lags 2; f b diff f b

# nls estimation of cointegrating vector

ols b const f

scalar b1 = \$coeff(const)

scalar b2 = \$coeff(f)

ols d_b const d_f(0 to -1)

scalar d0 = \$coeff(d_f)

scalar d1 = \$coeff(d_f_1)

ols b const b(-1) f(0 to -1)

scalar a = 1-\$coeff(b_1)

nls d_b=-a*(b_1-b1-b2*f_1)+d0*d_f+d1*d_f(-1) params a b1 b2 d0 d1 end nls

scalar theta1 = 1-\$coeff(a)

series ehat = b-\$coeff(b1)-\$coeff(b2)*f

 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

Augmented Dickey-Fuller test for f including^ne lag of (1-L)^(rr. ax was 4) sample size 102

unit-root null hypothesis: a = 1

test with constant.

model: (l-L)y = bO + (a-l)*y(-l) + … + e

lst-order autocorrelation coeff. for e: -0.051 estimated value of (a – 1): -0.0446213 test statistic: tau c(l) .50432^)

asymptotic p-value 0.1143^)

with constant and trend

model: (l-L)y = bO + bl*t + (a-l)*y(-l) + … + e lst-order autocorrelation coeff. for e: -0.087 estimated value of (a – 1): -0.0922337 test statistic: tau_ct(l) = -3.48196 asymptotic p-value 0.04127

Figure 12.7: The ADF test results.

Cointegratinc^rec^ressior^^

OLS, using observations 1984:1-2009:4 (T = 104) Dependent variable: f