Skip to content

Granger's causality test

2 messages · rafleon at highstat.cl, Matthieu Stigler

#
Hi all,
I've got several time series as these below

tacc=c(106, 117, 125, 140, 150, 150, 135, 135, 102, 102, 112, 124, 128,
128)
value=c(1273, 1464, 1799, 1440,  963,  817,  794,  791,  638,  954, 1301,
2007, 1998, 2000)

#######
Additional information
tacc= Total Allowable Commercial Catch, In this case rock lobster in New
South Wales, Australia.
Value= The tacc is split into Individual Transferable Quotas (ITQs), which
can be leased or sold. In this case Value is the sale price]
The tacc is set every year and every stakeholder (commercial, recreational
fisher association, conservationists, aborigines, fisheries manager) can
suggest a figure for the tacc and the final decision is made by the
Minister.
I'm expecting that lower tacc cause higher value. Why? because lower tacc
produce stock rebuilding, increasing catch rates, which in turn reduces
fishing costs and improve future catches expectation and finally this
increase the quota prices.
######

I'm traying to find 'causality' between these variables. Well, I used the
function grangertest

library(lmtest)
grangertest(tacc ~ value, order = 1)
grangertest(value ~ tacc , order = 1)

Additionally, I found the below fucntion on internet that return different
results.
Please, could someone of you tell me which function is more reliable? And,
I don't understand the k parameter.
I would appreciate deeply any help.
Cheers,

Rafael



ts=cbind(value,tacc)
#Note that the results are different if ts=cbind(tacc,value)

"granger" <-function(d, L, k=1 )
{
#d is a bivariate time-series:  regress d[,k] on L lags of d[,1] and
d[,2].
#This is a modified version for R, in which the command ts.matrix was
substituted by ts.intersect.
names.d <- dimnames(d)[[2]]
D <- d
for(i in 1:L)
{
D <-ts.intersect(D, lag(d,  - i))
#don't you find -1 bizarre here and it annoying to need the loop
}
dimnames(D)[[2]] <- paste(rep(names.d, L + 1), "_", rep(0:L, times =
rep(2, L + 1)), sep = "")
y  <- D[, k]
n  <- length(y)
x1 <- D[,  - (1:2)]
x0 <- x1[, ((1:L) * 2) - (k %% 2)]
z1 <- lm(y ~ x1)
z0 <- lm(y ~ x0)
S1 <- sum(z1$resid^2)
S0 <- sum(z0$resid^2)
ftest <- ((S0 - S1)/L)/(S1/(n - 2 * L - 1))
list(ftest = ftest, p.val = 1 - pf(ftest, L, n - 2 * L - 1), R2 =
summary(z1)$r.squared)
}

granger(ts,L=1, k=2)
#
Rafael

I don't know about the function found on the test, but you can rely on 
the function grangertest!

Note also you could use causality() from vars pkg, which gives exactly 
the same output:
library(vars)
v<-VAR(cbind(tacc, value))

causality(v, cause="value")$Granger
grangertest(tacc ~ value, order = 1)

Note that, although the F stat is the same, the df and p-values are not 
exactly the same: grangertest() is considered as a univariate 
regression, while causality() considers you have been estimating a full 
VAR. See Lutkephol (2006) p. 103 for a discussion on the choice of df. 
The advantage of the causality(9 function is that it allows to use HC 
covariance estimators for the test.

Hope this helps

Matthieu


Le 17/11/2011 02:57, rafleon at highstat.cl a ?crit :