Preamble

This lecture is based on Cowpertwait & Metcalfe, Introductory Time Series with R, Chapter 11.

library("forecast")
library("tseries")

Exchange Rate Data

# Daily exchange rates for UK pounds and the Euro, 
# from January 2004 to December 2007, per US dollar.
#
xrates <- read.table("http://www.maths.adelaide.edu.au/andrew.metcalfe/Data/us_rates.dat",
                     header=TRUE)
n <- nrow(xrates)
time <- 1:n

euro <- xrates$EU
gbp <- xrates$UK

Time Series Plots

ylim <- range(euro, gbp)
plot(time, euro, ylim=ylim, type="l", col=2, ylab="Exchange Rate", xlab="Time")
lines(time, gbp, col=3)
legend("topright", inset=0.025, legend=c("euro", "gbp"), col=c(2, 3), lty=2)

ACFs, PACFs for Euro

Euro

par(mfrow=c(1,2))
Acf(euro)
Pacf(euro)

Diff. Euro

par(mfrow=c(1,2))
Acf(diff(euro))
Pacf(diff(euro))

2nd Diff. Euro

par(mfrow=c(1,2))
Acf(diff(diff(euro)))
Pacf(diff(diff(euro)))

ACFs, PACFs for GBP

Great Britain Pound

par(mfrow=c(1,2))
Acf(gbp)
Pacf(gbp)

Diff. Great Britain Pound

par(mfrow=c(1,2))
Acf(diff(gbp))
Pacf(diff(gbp))

2nd Diff. Great Britain Pound

par(mfrow=c(1,2))
Acf(diff(diff(gbp)))
Pacf(diff(diff(gbp)))

Dickey-Fuller Test for Euro

Step 1: Least Squares Fit

lag.euro <- c(NA, euro)[1:length(euro)]
lsfit.euro <- lm(euro ~ lag.euro)
summary(lsfit.euro)

Call:
lm(formula = euro ~ lag.euro)

Residuals:
       Min         1Q     Median         3Q        Max 
-0.0151592 -0.0025000 -0.0000257  0.0023317  0.0167769 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 0.001734   0.002529   0.686    0.493    
lag.euro    0.997650   0.003219 309.915   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.004238 on 1000 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9897,    Adjusted R-squared:  0.9897 
F-statistic: 9.605e+04 on 1 and 1000 DF,  p-value: < 2.2e-16

Step 2: Compute Test Statistic

(tau.mu.euro <- (0.997650 - 1) / (0.003219))
[1] -0.7300404

Step 3: Perform Test

Use value of n to find appropriate row of Table 8.5.2:

print(n)
[1] 1003

With n > 1000, use the “n = 500” or “n = Infinity” row of the table. Since -2.57 < tau.mu < -0.44, it follows that 0.10 < p < 0.90. We do not reject the null hypothesis; we do not have evidence that euro is not a random walk.

Dickey-Fuller Test for GBP

Step 1: Least Squares Fit

lag.gbp <- c(NA, gbp)[1:length(gbp)]
lsfit.gbp <- lm(gbp ~ lag.gbp)
summary(lsfit.gbp)

Call:
lm(formula = gbp ~ lag.gbp)

Residuals:
       Min         1Q     Median         3Q        Max 
-0.0112134 -0.0016760 -0.0000435  0.0016229  0.0115767 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 0.003095   0.001880   1.646      0.1 .  
lag.gbp     0.994113   0.003510 283.217   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.002873 on 1000 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9877,    Adjusted R-squared:  0.9877 
F-statistic: 8.021e+04 on 1 and 1000 DF,  p-value: < 2.2e-16

Step 2: Compute Test Statistic

(tau.mu.gbp <- (0.994113 - 1) / (0.003510))
[1] -1.677208

Step 3: Perform Test

Use value of n to find appropriate row of Table 8.5.2:

print(n)
[1] 1003

As with Euro, since -2.57 < tau.mu < -0.44, it follows that 0.10 < p < 0.90. We do not reject the null hypothesis; we do not have evidence that GBP is not a random walk.

Ad-Hoc Test for Cointegration

Least Squares Fit

fit <- lm(euro ~ gbp)
summary(fit)

Call:
lm(formula = euro ~ gbp)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.054435 -0.009254  0.000994  0.009364  0.031663 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.031320   0.008826  -3.548 0.000405 ***
gbp          1.525231   0.016484  92.527  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.0135 on 1001 degrees of freedom
Multiple R-squared:  0.8953,    Adjusted R-squared:  0.8952 
F-statistic:  8561 on 1 and 1001 DF,  p-value: < 2.2e-16

Fit Residuals vs. Lag

resid <- residuals(fit)
lag.resid <- c(NA, resid)[1:length(resid)]
fit.resid <- lm(resid ~ lag.resid)
summary(fit.resid)

Call:
lm(formula = resid ~ lag.resid)

Residuals:
       Min         1Q     Median         3Q        Max 
-0.0128295 -0.0015814  0.0001989  0.0016803  0.0095878 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) -2.579e-05  8.709e-05  -0.296    0.767    
lag.resid    9.846e-01  6.503e-03 151.414   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.002757 on 1000 degrees of freedom
  (1 observation deleted due to missingness)
Multiple R-squared:  0.9582,    Adjusted R-squared:  0.9582 
F-statistic: 2.293e+04 on 1 and 1000 DF,  p-value: < 2.2e-16

Perform DF Test on Residuals

(tau.mu.resid <- ((9.846e-01) - 1) / (6.503e-03))
[1] -2.368138

Since -2.57 < tau.mu < -0.44, we have 0.10 < p < 0.90. We cannot reject the null that the two series are not cointegrated. We do not have evidence of co-integration.

Phillips-Ouliaris Test for Cointegration

po.test(cbind(euro, gbp))

    Phillips-Ouliaris Cointegration Test

data:  cbind(euro, gbp)
Phillips-Ouliaris demeaned = -17.13, Truncation lag parameter = 10,
p-value = 0.09844

Note: test is sensitive to order (also true for ad-hoc procedure above).

po.test(cbind(gbp, euro))

    Phillips-Ouliaris Cointegration Test

data:  cbind(gbp, euro)
Phillips-Ouliaris demeaned = -21.662, Truncation lag parameter = 10,
p-value = 0.04118

Conclusion: some weak evidence of co-integration.

Residual Plots

Time Series Plot

plot(time, resid, type="l")

ACF, PACF of Residuals

par(mfrow=c(1,2))
Acf(resid)
Pacf(resid)