Write the code for this in R for a 5 series using Y, I am doing price discovery forgeneralized information share (GIS) and Gonzalo and Granger permanent-temporary decomposition (PT-GG) based information share measures for the spot, futures, and three ETFs.
where β and α are n×(n−1) matrices of rank n−1. The columns of β consist of the n−1 cointegrating vectors, and each column of α consists of the adjustment coefficients. The matrix Π is decomposed in such a way that βTYt represents the vector of n−1 stationary series. Let Ω denote the n×n covariance matrix of the innovation vector, i.e., E[εtεtT]=Ω. Following Stock and Watson (1988), equation (1) can be transformed into the following two equivalent vector moving average (VMA) representations (Hasbrouck, 1995):
Based on the above representations, Ψ(1)εt represents the long-run impact of innovations on the unit-root series (Hasbrouck, 1995). Different information share measures considered by Hasbrouck (1995), Lien and Shrestha (2009), and Lien and Shrestha (2014) are based on this term.
\textbf{GENERALIZED INFORMATION SHARE (GIS) MEASURES}
Based on the above framework, we first discuss the GIS measure. Note that, in this study, we have five non-stationary series with four cointegrating vectors. Therefore, the cointegrating vector represented by matrix β can be expressed as follows:
In other words, equation (4) implies that the first row of Ψ(1) is equal to the γj−1 times the jth row of Ψ(1). Therefore, the long-run impact of innovations on the ith series is respectively given by
where ψij is the jth element of ψir and Ωij is the (i,j)th element of Ω.
Let Sj,i denote the contribution of the innovation of series j to the total variance of the \textit{long-run impact} of innovation on series i. Then, we have the following:
Note that Sj,i is independent of i. Therefore, the contribution of the innovation of series j to the total variance of the \textit{long-run impact} of innovation on any series will be the same. It is important to note that Sj,i given by equation (9) is valid only when the innovations are independent. However, in general, the innovations are not independent. When the innovations are not independent, we diagonalize the correlation matrix and end up with the GIS measure proposed by Lien and Shrestha (2014). Let Λ be a diagonal matrix containing the eigenvalues of the innovation correlation matrix on the diagonal, where the corresponding eigenvectors are given by the columns of matrix G. Then, we can calculate the information share of the jth series as follows:
where ψ1G=ψ1rFM,FM=[GΛ−1/2GTV−1]−1 and ψjG is the jth element of ψ1G. The information share measure given by equation (10) is referred to as the generalized information share (GIS) measure. It can be shown that the GIS measure is independent of ordering. Therefore, the GIS method leads to a unique information share, unlike the upper and lower bound for Hasbrouck IS measure.
\vspace{1cm}
\textbf{GONZALO-GRANGER PERMANENT TEMPORARY DECOMPOSITION (PT/GG) INFORMATION SHARE}
Here, we briefly describe the PT/GG method. Gonzalo and Granger (1995) propose a way of decomposing the vector of non-stationary series Yt into permanent component ft (non-stationary series) and transitory (stationary) component Y^t, where the identification of these components is achieved by assuming that (i) the permanent component is a linear function of the original series and that (ii) the transitory component does not Granger cause the permanent component in the long-run.
The permanent component ft (under the linearity condition) can be written as:
[
f_t = \mu^T Y_t \tag{11}
]
where μ is an n×1 (or, 5 × 1 in this study) permanent component coefficient vector which can be shown to be orthogonal to the adjustment coefficient matrix α, i.e., μ=α⊥.
In our study, since we have five unit-root series, the permanent component, ft can be represented by:
[
f_t = \mu_1 Y_1 t + \mu_2 Y_2 t + \cdots + \mu_5 Y_5 t \tag{12}
]
If all the elements of μ are non-negative, then the PT/GG based information share of the ith series is given by:
In the case of non-negative μ, its elements correspond to the contribution of individual series to the permanent component. Therefore, the above definition of price discovery makes sense. However, there is no guarantee that all the elements of μ will be non-negative. It is important to note that the negative elements of μ may not necessarily lead to problems. For example, if some of the unit-root processes are negatively related to the common-stochastic trend, we expect the corresponding elements of μ to be negative. In such cases, where the negative elements of μ are valid, we can use the following definition of information share:
However, if some of the elements of μ are unexpectedly negative, one way to compute the PT/GG based information share is to replace the negative elements with zero and use equation (13). However, this will lead to all negative elements having zero information share regardless of their absolute value. Alternatively, we can add a constant number to each element of μ to obtain μ∗ so that the series with the most negative element in μ will have zero information share. This method will result in the following information share measure:
The data starts from 6 December 2007 to 31 December 2019, with a total number of 3,012 observations. We chose the starting date to be 6 December 2007 because this is the earliest date for which the data for all five prices are available. The data set includes the daily WTI crude oil spot and near month crude oil futures prices. The data set also includes prices of three crude oil future-based ETFs. We focus on oil ETFs that replicate the WTI spot Cushing through the nearby month futures contracts. The three oil ETFs that replicate the WTI spot Cushing through the nearby month futures contracts are:
\begin{itemize}
\item United States Oil Fund (USO),
\item iPath S&P GSCI Crude Oil Total Return (OIL), and
\item United States 12 Month Oil Fund (USL).
\end{itemize}
Throughout the empirical analyses, we use the logarithm of the prices. Table 1 presents detailed information on the three oil-based ETFs, including their ticker codes, inception dates, asset under management, and trading volumes. The USO accounts for around 77% of the assets under management, while OIL and USL account for 19% and 4%, respectively.
\begin{table}[ht]
\centering
\caption{Information of ETFs}
\begin{tabular}{|l|l|l|l|l|}
\hline
\textbf{Ticker Code} & \textbf{ETFs} & \textbf{Inception Date} & \textbf{Asset Under Management} & \textbf{Trading Volume} \
& & & \textbf{(in USD million)} & \ \hline
U:USO & United States Oil Fund & 10-04-2006 & 2,510 & 16,012,332 \
U:OIL & iPath S&P GSCI Crude Oil Total Return ETN & 16-08-2006 & 628.87 & 7,109,239 \
U:USL & United States 12 Month Oil Fund Limited Partnership & 06-12-2007 & 104.84 & 26,720 \ \hline
\end{tabular}
\end{table}
The price discovery is measured using GIS and PT/GG information share measures. To compute these two IS measures, we need to validate that each of the log-price series used in this study is non-stationary with a single unit-root. We use the Phillips-Perron (PP) unit-root test, where the unit-root is the null hypothesis. Table 2 presents the unit-root test results for the crude oil spot, futures, and the three ETFs.
***, **, * indicate the test statistic to be significant at the 1%, 5%, and 10% significance levels, respectively.
All the PP test statistics for log-price series are insignificant, even at the 10% level. Also, all the PP test statistics for the first differenced log-price series are significant even at the 1% level. These results indicate that all the series are integrated of order one, i.e., each of the series consists of a single unit-root. To check the robustness of our test results, we also apply the KPSS test, where the null hypothesis is stationarity. The KPSS test statistics for log prices are highly significant even at the 1% level, which rejects the null hypothesis of stationarity.
However, none of the KPSS statistics is significant for the first differenced series even at the 10% level. Therefore, both PP and KPSS tests reveal a consistent result where each of the series consists of a single unit-root.
We then proceed to examine the number of cointegrating vectors. As discussed earlier, we are dealing with five series. Therefore, to compute GIS and PT/GG information share measures, we need to establish that there are four cointegrating vectors. We apply the Johansen (1991) cointegration test to find the number of cointegrating vectors. Table 3 reports the λmax and Trace statistics. The λmax statistics for the number of cointegrating vectors (r) less than or equal to 3 is significant even at the 1% level. However, the λmax statistics for the number of cointegrating vectors (r) less than or equal to 4 is insignificant even at the 10% level. Similarly, the Trace statistics for the number of cointegrating vectors (r) less than or equal to 3 is significant at the 1% level. Therefore, we conclude that the number of cointegrating vectors is equal to 4.
with γ1=0.9999, γ2=0.4034, γ3=0.3467, and γ4=0.6690. Even though γ1 is approximately equal to 1, other γs are significantly different from 1. Therefore, Hasbrouck information shares cannot be computed in this case. The GIS and PT/GG methods are the right models to use in such a case.
The GIS measures for the five series are presented in Table 4. Only approximately 41 percent of the price discovery takes place in the futures market. The remaining 59 percent of the price discovery takes place in the other four markets that include the spot and the three ETF markets. Approximately 25 percent of the price discovery occurs in the USO market. As to the remaining two ETFs, around 11 and 6 percent of the price discovery take place in the USL and OIL markets, respectively. In total, approximately 42 percent of the price discovery takes place in the three ETFs markets.
In sum, we find that ETFs play a significant price discovery role, and additional ETFs play an additional price discovery role. Therefore, additional ETFs are not redundant.
\end{document}
To perform the price discovery analysis using the Generalized Information Share (GIS) and Gonzalo and Granger Permanent-Temporary decomposition (PT-GG) measures in R, you will need the following steps. The provided code will guide you through using R to estimate the vector error correction model (VECM), from which you can calculate the necessary decomposition matrices and ultimately the GIS and PT-GG measures.
# Install and load necessary packages
if (!requireNamespace("vars", quietly = TRUE)) {
install.packages("vars")
}
if (!requireNamespace("tseries", quietly = TRUE)) {
install.packages("tseries")
}
library(vars)
library(tseries)
# Sample data
# Assuming log_data is already loaded from your workspace and is a data frame
Y <- log_data[, c("log_Spot", "log_Fut", "log_USO", "log_USL", "log_OIL")]
# Check for unit-roots using Phillips-Perron test
pp_tests <- lapply(Y, function(series) {
pp.test(series, alternative = "stationary")
})
# Verify if all series are I(1)
print(pp_tests)
# Fit VECM to find cointegrating relationships
# Use the Johansen test to determine the number of cointegration vectors
vecm_model <- ca.jo(Y, type = "trace", K = 2, ecdet = "const", spec = "transitory")
# Summary of the VECM model
summary(vecm_model)
# Extract relevant matrices from the VECM result
alpha <- vecm_model@VECM@model$Pi
betaT <- vecm_model@VECM@model@CRK
# Calculate Ω (covariance matrix of residuals)
Omega <- cov(residuals(vecm_model))
# Implement calculations for GIS
# Calculate Psi(1) and its long run impact.
Psi_1 <- solve(diag(nrow(Omega)) - alpha %*% t(betaT))
# Information Share calculations for each series
S_jG <- apply(Psi_1, 1, function(psi_1) {
sum((psi_1 %*% Omega %*% t(psi_1)))
})
# Normalization of Information Share
S_jG_normalized <- S_jG / sum(S_jG)
# Print Information Share
print(S_jG_normalized)
# Perform Gonzalo-Granger decomposition
# Obtain orthogonal complement of alpha
alpha_perp <- qr.Q(qr(t(alpha)), complete = TRUE)[, -(1:4)]
# Calculate Permanent component contribution
mu <- alpha_perp
# Check for non-negativity
PTGG <- ifelse(all(mu >= 0), mu / sum(mu), abs(mu) / sum(abs(mu)))
# Print PT-GG Information Share
print(PTGG)
Note:
Ensure your log_data dataframe is correctly formatted to include the log-transformed series before running this script.
Adjust the K parameter in the ca.jo function to the number of lags based on the best fit for your time-series data which may vary across applications. Often, a lag length selection criterion such as AIC or BIC can help determine the appropriate lag length.
The code assumes five endogenous variables and one deterministic term in VECM. Adjust accordingly if that structure changes.
Depending on the cointegration logic, verify if Psi(1) calculations align methodologically with the theory detailed in your document, especially concerning the eigen-structure methods and the diagonalization process for correlated innovations.
This code provides a foundational approach to understanding price discovery between markets, allowing interpretation using the discussed economic metrics—GIS and PT-GG.