关键词 > ECON20110/30370

ECON 20110/30370: Econometrics Semester 2 – Practical Session Worksheet 4

发布时间:2024-05-15

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Semester 2 – Practical Session Worksheet 4

ECON 20110/30370: Econometrics

This practical session explores the dynamic relationship between gold and silver prices, focusing on unit root tests, spurious regressions, and Granger causality.

1    Load the Data

We will analyse the ‘GoldSilver’ dataset from the ‘AER ’ library, comprising daily spot prices for gold (per 0.1 oz) and silver (per 10 oz) from December 30, 1977, to December 31, 2012.  This multivariate dataset provides a rich basis for our exploration.

To load this dataset into R, execute the following commands:

library(AER)

data("GoldSilver")

1.1    Data Preparation

The data preparation involves log transforming the series to stabilise variance and compress the scale of the data.  This approach mitigates the disparity between small and large values, ensuring a more meaningful analysis. Furthermore, considering the extensive span of the dataset and to focus our investigation on more recent trends and dynamics between gold and silver prices, we concentrate on a subset of the data post-1990 using the window’ function.

Execute the following R code to prepare the data:

lgs  <-  log(GoldSilver)

lgs78  <-  window(lgs,  start  =  as.Date("1990-01-01"))

gold  <-  lgs78[,1]

silver  <-  lgs78[,2]

The final two lines of code precisely extract the ‘gold’ and ‘silver’ series from the adjusted multivariate dataset lgs78’, ensuring that our analysis is targeted and relevant.

2    Loading the Required Packages

To effectively carry out our analysis, we will use several R packages for dynamic linear modelling and hypothesis testing. Load the necessary packages into your R session as follows:

library(dynlm)

library(car)

This enables the use of ‘dynlm()’ for dynamic modelling and linearHypothesis()’ for performing F-tests, among other analytical capabilities.

3    Analysis of Gold and Silver Prices

This exercise focuses on the dynamic relationship between gold and silver prices, with a focus on unit root tests, the detection of spurious regressions, and the understanding of Granger causality.  Our objective is to interpret the results of statistical tests to gain insights into the properties of the time series data and their relationship.

3.1    Testing for Unit Roots

Determining whether the gold and silver price series are integrated — that is, if they contain unit roots — is our first analytical step. This is crucial for understanding the time series’ characteristics and selecting the appropriate modelling techniques.

1.  Visual Inspection:

Start by closely examining the plot of the log-transformed prices. Observe and discuss any discernible patterns, and compare the two series with respect to their volatility and trends.   This initial visual inspection is an essential preliminary step for gaining insight into the underlying behaviour of the series.

2.  Performing Unit Root Tests:

The Augmented Dickey-Fuller (ADF) test will help us assess the presence of unit roots in both gold and silver price series.

(a)  The use of information criteria such as the  BIC and AIC has determined that an autoregressive model of order one, AR(1), is suitable for both the gold and silver price series.

Discuss the implications of this finding for the number of unit roots present in each series.  (You may assume that the innovation term comes from an i.i.d. white noise process.)

(b)  What should be the dependent variable in the ADF regression for testing unit roots in prices? Based on AR(1) modelling for the level, consider the appropriate number of lags of the first difference that should be included in the ADF regression for each series.

(c)  Investigate the number of stochastic trends in the gold series using a general-to-specific approach: i.  Trend-inclusive ADF Test:

Start with an ADF regression that includes both a trend and a constant:

Δgoldt  = α0 +δ · t + π · goldt  1 +ut .

A.  Discuss the implications of the test results for the presence of unit roots, focusing on what rejection and failure to reject the null hypothesis imply about the series’ properties.

B.  Use this code to fit the model:

gold_ADFtrend  <-  dynlm(diff(gold)  ~  L(gold,  1)+trend(gold)) summary(gold_ADFtrend)

(Note: The  diff(gold)function calculates the first difference of the series, while trend(gold)  adds a time trend according to the length of the series.)

To test the joint hypothesis that π = δ = 0, execute:

linearHypothesis(gold_ADFtrend,

c("L(gold,  1)  ",  "trend(gold)"))

ii.  Constant-only ADF Test:

Next, examine an ADF model with only a constant:

Δgoldt  = α0 + π · goldt  1 +ut

using this code:

gold_ADFconstant  <-  dynlm(diff(gold)  ~  L(gold,  1))

summary(gold_ADFconstant)

To test the joint hypothesis that π = α0  = 0, use:

linearHypothesis(gold_ADFconstant,

c("L(gold,  1)  ",  "(Intercept)"))

iii.  No-constant ADF Test:

Lastly, consider an ADF model without a constant or trend:

Δgoldt  = π · goldt  1 +ut

Implement with:

gold_ADFnon  <-  dynlm(diff(gold)  ~  0+L(gold,  1))

summary(gold_ADFnon)

(Note: Specifying 0 forces the exclusion of an intercept.)

iv.  Based on the 5% significance level, decide on the most appropriate test specification for determining the presence of a unit root in the level of the gold price series’ .

v.  Determine the necessity of testing for unit roots in the first differences.  What do the ADF test resultsimply about the gold series’ integration order?

(d)  Repeat the analysis for the silver series, applying the general-to-specific approach to conclude its order of integration.

3.2    Detecting Spurious Regression

A common challenge in time series analysis is distinguishing between spurious relationships and genuine correlations, especially with non-stationary data.  Spurious regression can lead to misleading conclusions about the economic relationships between variables.

1.  Naive Regression Analysis:


Begin by regressing gold prices on silver prices:

goldt  = β0 +β1 silvert +ut,

using the code:

SR  <-  dynlm(gold~silver)

summary(SR)

Consider the potential implications of conducting such an analysis without first confirming stationarity in the series. Reflect on how the presence of unit roots, as identified in the earlier tests, might affect the validity of this regression analysis.

2.  Addressing Spuriousness:

(a)  Regression of First Differences:

To mitigate the risks of spurious regression, re-examine the relationship by regressing the first differences of gold prices on the first differences of silver prices:

Δgoldt  = β0 +β1Δsilvert +ut                                                                      (1)

by running:

SR2<-  dynlm(diff(gold)~diff(silver))

summary(SR2)

Discuss how differencing, a method that can induce stationarity in non-stationary series, may

alter the interpretation of the relationship between gold and silver prices from part (a). (b)  Inclusion of Lagged Terms:

Further refine the analysis by including a lagged term of gold prices in the level model:

goldt  = β0 +β1 silvert α1goldt  1 +ut .

using:

SR3  <-  dynlm(gold~silver+L(gold,1))

summary(SR3)

Consider how the addition of lagged term not only addresses the issue of spuriousness but also provides insights into the properties of the gold series itself.

Discuss the implications of this model’s results for understanding the economic relationship be- tween these two commodities.


3.3    Exploring Granger Causality

The concept of Granger causality is fundamental to time series analysis, providing a framework to examine the predictive relationships between variables. Its application is especially relevant for stationary time series, where the stability of the series’ properties over time bolsters the reliability of forecasts.

In this section, we explore the intricacies of Granger causality, focusing on its application to station- ary variables.  By examining Granger causality in this context, we aim to uncover the directional influence between variables, offering valuable perspectives on their dynamic interplay.

1.  Understanding Granger Causality:

Begin by articulating your understanding of Granger causality. How does it differ from causality in the classical sense? In the context of gold and silver prices, what implications would there be if we found that gold prices Granger-cause silver prices, or vice versa?

Consider the regression of first differences in equation (1) and discuss whether it is adequate for a Granger causality test.  What elements would be necessary to formally test for Granger causality be- tween these two series?

2.  The Granger-Causality Test:

Conduct a Granger causality test by analysing the relationship between gold and silver prices through the following model:

Δgoldt  = β0 +β1Δsilvert  1 + α1Δgoldt  1 +ut,

using the code:

Granger<-  dynlm(diff(gold)~+L(diff(gold),1)+L(diff(silver),1)) summary(Granger)

In examining the model’s output:

(a)  Describe how one would determine the existence of Granger causality between gold and silver prices.

(b)  Discuss the implications of the regression results for the predictive relationships between these series. Consider how these insights might influence investors or market analysts focusing on the gold and silver markets, especially in terms of forecasting future price movements.