简体   繁体   English

在 R 中使用 VECM 进行格兰杰因果关系检验

[英]Granger causality test using VECM in R

I am trying to compute the Granger causality test using the Vector Error Correction Model (VECM) in R. I calculated the VECM in R using tsDyn package.我正在尝试使用 R 中的向量误差校正模型 (VECM) 计算 Granger 因果关系检验。我使用tsDyn包计算了 R 中的 VECM。 Since I have I (1) and cointegrated variables, VECM is assumed to implement the Granger causality test.由于我有I (1) 和协整变量,因此假设 VECM 执行格兰杰因果检验。 However I didn't find any function in R, that could perform the Granger Granger causality test for VECM.但是我没有在 R 中找到任何可以对 VECM 执行 Granger Granger 因果关系检验的函数。 I would like to ask You, whether someone does know such a function.我想问你,是否有人知道这样的功能。 Here is my example:这是我的例子:

dols.est <- dynlm(ts_ln.API.real.1~ts_MR.var.nom.1+L(d(ts_MR.var.nom.1), -3:3)) # Estimate θ with DOLS

est.theta <- dols.est$coefficients[2]

int.mts <- ts.union(ts_ln.API.real.1, ts_MR.var.nom.1) # Create a multivariate time series

VEC.est <- VECM(int.mts, lag=1, r=1, include = c("both"), beta = est. theta)

Any help will be greatly appreciated.任何帮助将不胜感激。 Thank You in advance!先感谢您!

0 Before all, perform ADF test by taking into account the usage of common sample for all the lags. 0首先,通过考虑所有滞后的公共样本的使用来执行ADF测试。 For example: (causfinder::adfcs and causfinder::adfcstable):例如:(causfinder::adfcs 和 causfinder::adfcstable):

adfcs <- function (t, max = floor(12 * (length(t)/100)^(1/4)), type = c("c"))  
# Augmented Dickey-Fuller function that takes into account the usage of common sample for all the lags
{
    x <- ts(t)
    x1d <- diff(x, differences = 1)
    x1l <- lag(x, -1)
    if (max == 0) {
        x_names <- c("x1d", "x1l")
        DLDlag <- ts.intersect(x1d, x1l)
        DLDlag.df <- data.frame(DLDlag, obspts = c(time(DLDlag)))
    }
    else {
        x_names <- c("x1d", "x1l", sapply(1:max, function(i) paste("x1d", i, "l", sep = "")))
    }
    if (max != 0) {
        for (i in as.integer(1:max)) {
            assign(x_names[i + 2], lag(x1d, -i))
        }
        DLDlag <- do.call(ts.intersect, sapply(x_names, as.symbol))
        DLDlag.df <- data.frame(DLDlag, obspts = c(time(DLDlag)))
        DifferenceLags <- as.vector(names(DLDlag.df), mode = "any")[3:(length(DLDlag.df) - 1)]
    }
    lmresults <- array(list())
    SBCvalues <- array(list())
    AICvalues <- array(list())
    for (i in as.integer(0:max)) {
        if (type == c("nc")) {
            if (i == 0) {
                lmresults[[max + 1]] <- lm(as.formula(paste("x1d ~x1l")), data = DLDlag.df)
                SBCvalues[[max + 1]] <- BIC(lmresults[[max + 1]])
                AICvalues[[max + 1]] <- AIC(lmresults[[max + 1]])
            }
            if (i > 0) {
                lmresults[[i]] <- lm(as.formula(paste("x1d ~ x1l+", paste(DifferenceLags[1:i], collapse = "+"))), data = DLDlag.df)
                SBCvalues[[i]] <- BIC(lmresults[[i]])
                AICvalues[[i]] <- AIC(lmresults[[i]])
            }
        }
        if (type == c("c")) {
            if (i == 0) {
                lmresults[[max + 1]] <- lm(as.formula(paste("x1d ~1+x1l")), data = DLDlag.df)
                SBCvalues[[max + 1]] <- BIC(lmresults[[max + 1]])
                AICvalues[[max + 1]] <- AIC(lmresults[[max + 1]])
            }
            if (i > 0) {
                lmresults[[i]] <- lm(as.formula(paste("x1d ~ 1+x1l+", paste(DifferenceLags[1:i], collapse = "+"))), data = DLDlag.df)
                SBCvalues[[i]] <- BIC(lmresults[[i]])
                AICvalues[[i]] <- AIC(lmresults[[i]])
            }
        }
        if (type == c("ct")) {
            if (i == 0) {
                lmresults[[max + 1]] <- lm(as.formula(paste("x1d ~ 1+x1l+seq_along(x1d)", collapse = "")), data = DLDlag.df)
                SBCvalues[[max + 1]] <- BIC(lmresults[[max + 1]])
                AICvalues[[max + 1]] <- AIC(lmresults[[max + 1]])
            }
            if (i > 0) {
                lmresults[[i]] <- lm(as.formula(paste("x1d ~ 1+x1l+seq_along(x1d)+", paste(DifferenceLags[1:i], collapse = "+"))), data = DLDlag.df)
                SBCvalues[[i]] <- BIC(lmresults[[i]])
                AICvalues[[i]] <- AIC(lmresults[[i]])
            }
        }
    }
    out <- list()
    out$optmins <- list(which.min(SBCvalues), which.min(AICvalues))
    out$SBCAIC <- as.data.frame(cbind(SBCvalues, AICvalues))
    typespecified <- type
    if (which.min(SBCvalues) == max + 1) {
        scs <- (max + 2) - (0 + 1)
        out$adfcst <- unitrootTest(x[scs:length(x)], lags = 0, 
            type = typespecified)
    }
    else {
        scs <- (max + 2) - (which.min(SBCvalues) + 1)
        out$adfcst <- unitrootTest(x[scs:length(x)], lags = which.min(SBCvalues), 
            type = typespecified)
    }
    out
}

and of course, one can present whole the related ADF statistics in a table (as we did in our CAD paper in Procedia) which is given by causfinder::adfcstable:当然,我们可以在一个表格中显示整个相关的 ADF 统计数据(就像我们在 Procedia 的 CAD 论文中所做的那样),该表格由 causfinder::adfcstable 给出:

adfcstable <- function (d, max = 5) 
{
    d <- as.data.frame(d)
    LevelADFtable <- matrix(, nrow = dim(d)[[2]] * 3, ncol = 10)
    FirstDiffADFtable <- matrix(, nrow = dim(d)[[2]] * 3, ncol = 9)
    Result <- matrix(, nrow = dim(d)[[2]] * 3, ncol = 1)
    ADFtable <- as.data.frame(cbind(LevelADFtable, FirstDiffADFtable, Result), stringsAsFactors = FALSE)
    colnames(ADFtable) <- c("var", "type", "inc", "levelt", "Pc", "c", "Pt", "t", "prob", "omlo", "type", "inc", "1stDifft", "Pc", "c", "Pt", "t", "prob", "omlo", "intorder")
    for (i in as.integer(1:dim(d)[[2]])) {
        for (j in as.integer(1:3)) {
            ADFtable[3 * (i - 1) + j, 1] <- colnames(d)[[i]]
        }
        ADFtable[3 * i - 2, 2] <- "dt"
        ADFtable[3 * i - 2, 11] <- "dt"
        ADFtable[3 * i - 1, 2] <- "d"
        ADFtable[3 * i - 1, 11] <- "d"
        ADFtable[3 * i, 2] <- "-"
        ADFtable[3 * i, 11] <- "-"
        ADFtable[3 * i - 2, 3] <- round(adfcs(d[, i], type = c("ct"))$adfcst@test$regression$coefficients[2, 1], digits = 3)
        ADFtable[3 * i - 1, 3] <- round(adfcs(d[, i], type = c("c"))$adfcst@test$regression$coefficients[2, 1], digits = 3)
        ADFtable[3 * i, 3] <- round(adfcs(d[, i], type = c("nc"))$adfcst@test$regression$coefficients[1, 1], digits = 3)
        ADFtable[3 * i - 2, 12] <- round(adfcs(diff(d[, i], differences = 1), type = c("ct"))$adfcst@test$regression$coefficients[2, 1], digits = 3)
        ADFtable[3 * i - 1, 12] <- round(adfcs(diff(d[, i], differences = 1), type = c("c"))$adfcst@test$regression$coefficients[2, 1], digits = 3)
        ADFtable[3 * i, 12] <- round(adfcs(diff(d[, i], differences = 1), type = c("nc"))$adfcst@test$regression$coefficients[1, 1], digits = 3)
        ADFtable[3 * i - 2, 4] <- round(adfcs(d[, i], type = c("ct"))$adfcst@test$statistic, digits = 3)
        ADFtable[3 * i - 1, 4] <- round(adfcs(d[, i], type = c("c"))$adfcst@test$statistic, digits = 3)
        ADFtable[3 * i, 4] <- round(adfcs(d[, i], type = c("nc"))$adfcst@test$statistic, digits = 3)
        ADFtable[3 * i - 2, 13] <- round(adfcs(diff(d[, i], differences = 1), type = c("ct"))$adfcst@test$statistic, digits = 3)
        ADFtable[3 * i - 1, 13] <- round(adfcs(diff(d[, i], differences = 1), type = c("c"))$adfcst@test$statistic, digits = 3)
        ADFtable[3 * i, 13] <- round(adfcs(diff(d[, i], differences = 1), type = c("nc"))$adfcst@test$statistic, digits = 3)
        ADFtable[3 * i - 2, 5] <- round(adfcs(d[, i], type = c("ct"))$adfcst@test$regression$coefficients[1, 4], digits = 3)
        ADFtable[3 * i - 2, 7] <- round(adfcs(d[, i], type = c("ct"))$adfcst@test$regression$coefficients[3, 4], digits = 3)
        ADFtable[3 * i - 1, 5] <- round(adfcs(d[, i], type = c("c"))$adfcst@test$regression$coefficients[1, 4], digits = 3)
        ADFtable[3 * i - 1, 7] <- "X"
        ADFtable[3 * i, 5] <- "X"
        ADFtable[3 * i, 7] <- "X"
        ADFtable[3 * i - 2, 14] <- round(adfcs(diff(d[, i], differences = 1), type = c("ct"))$adfcst@test$regression$coefficients[1, 4], digits = 3)
        ADFtable[3 * i - 2, 16] <- round(adfcs(diff(d[, i], differences = 1), type = c("ct"))$adfcst@test$regression$coefficients[3, 4], digits = 3)
        ADFtable[3 * i - 1, 14] <- round(adfcs(diff(d[, i], differences = 1), type = c("c"))$adfcst@test$regression$coefficients[1, 4], digits = 3)
        ADFtable[3 * i - 1, 16] <- "X"
        ADFtable[3 * i, 14] <- "X"
        ADFtable[3 * i, 16] <- "X"
        if (ADFtable[3 * i - 2, 5] < 0.05) {
            ADFtable[3 * i - 2, 6] <- "s"
        }
        else {
            ADFtable[3 * i - 2, 6] <- " "
        }
        if (ADFtable[3 * i - 2, 7] < 0.05) {
            ADFtable[3 * i - 2, 8] <- "s"
        }
        else {
            ADFtable[3 * i - 2, 8] <- " "
        }
        if (ADFtable[3 * i - 1, 5] < 0.05) {
            ADFtable[3 * i - 1, 6] <- "s"
        }
        else {
            ADFtable[3 * i - 1, 6] <- " "
        }
        ADFtable[3 * i - 1, 8] <- "X"
        ADFtable[3 * i, 6] <- "X"
        ADFtable[3 * i, 8] <- "X"
        if (ADFtable[3 * i - 2, 14] < 0.05) {
            ADFtable[3 * i - 2, 15] <- "s"
        }
        else {
            ADFtable[3 * i - 2, 15] <- " "
        }
        if (ADFtable[3 * i - 2, 16] < 0.05) {
            ADFtable[3 * i - 2, 17] <- "s"
        }
        else {
            ADFtable[3 * i - 2, 17] <- " "
        }
        if (ADFtable[3 * i - 1, 14] < 0.05) {
            ADFtable[3 * i - 1, 15] <- "s"
        }
        else {
            ADFtable[3 * i - 1, 15] <- " "
        }
        ADFtable[3 * i - 1, 17] <- "X"
        ADFtable[3 * i, 15] <- "X"
        ADFtable[3 * i, 17] <- "X"
        ADFtable[3 * i - 2, 9] <- round(adfcs(d[, i], type = c("ct"))$adfcst@test$p.value[[1]], digits = 3)
        ADFtable[3 * i - 1, 9] <- round(adfcs(d[, i], type = c("c"))$adfcst@test$p.value[[1]], digits = 3)
        ADFtable[3 * i, 9] <- round(adfcs(d[, i], type = c("nc"))$adfcst@test$p.value[[1]], digits = 3)
        ADFtable[3 * i - 2, 18] <- round(adfcs(diff(d[, i], differences = 1), type = c("ct"))$adfcst@test$p.value[[1]], digits = 3)
        ADFtable[3 * i - 1, 18] <- round(adfcs(diff(d[, i], differences = 1), type = c("c"))$adfcst@test$p.value[[1]], digits = 3)
        ADFtable[3 * i, 18] <- round(adfcs(diff(d[, i], differences = 1), type = c("nc"))$adfcst@test$p.value[[1]], digits = 3)
        ADFtable[3 * i - 2, 10] <- round(adfcs(d[, i], type = c("ct"))$adfcst@test$parameter, digits = 3)
        ADFtable[3 * i - 1, 10] <- round(adfcs(d[, i], type = c("c"))$adfcst@test$parameter, digits = 3)
        ADFtable[3 * i, 10] <- round(adfcs(d[, i], type = c("nc"))$adfcst@test$parameter, digits = 3)
        ADFtable[3 * i - 2, 19] <- round(adfcs(diff(d[, i], differences = 1), type = c("ct"))$adfcst@test$parameter, digits = 3)
        ADFtable[3 * i - 1, 19] <- round(adfcs(diff(d[, i], differences = 1), type = c("c"))$adfcst@test$parameter, digits = 3)
        ADFtable[3 * i, 19] <- round(adfcs(diff(d[, i], differences = 1), type = c("nc"))$adfcst@test$parameter, digits = 3)
        if (sum(as.numeric(c(ADFtable[3 * i - 2, 9] < 0.05 && ADFtable[3 * i - 2, 3] < 0, ADFtable[3 * i - 1, 9] < 0.05 && ADFtable[3 * i - 1, 3] < 0, ADFtable[3 * i, 9] < 0.05 && ADFtable[3 * i, 3] < 0))) > 1) {
            ADFtable[3 * i - 1, 20] <- "I(0)"
        }
        else {
            if (sum(as.numeric(c(ADFtable[3 * i - 2, 18] < 0.05 && ADFtable[3 * i - 2, 12] < 0, ADFtable[3 * i - 1, 18] < 0.05 && ADFtable[3 * i - 1, 12] < 0, ADFtable[3 * i, 18] < 0.05 && ADFtable[3 * i, 12] < 0))) > 1) {
                ADFtable[3 * i - 1, 20] <- "I(1)"
            }
            else {
                ADFtable[3 * i - 1, 20] <- "variableoi"
            }
        }
        ADFtable[3 * i - 2, 20] <- ""
        ADFtable[3 * i, 20] <- ""
    }
    ADFtable
}

1 Even for VECM models (eg, our variables are I(1) and cointegrated), we select number of lags based on information criteria on VAR model on levels of our time series. 1即使对于 VECM 模型(例如,我们的变量是 I(1) 并且是协整的),我们也会根据 VAR 模型在我们的时间序列水平上的信息标准来选择滞后数。 Functions of the same duty with differing capacity:不同容量的相同职责的功能:

vars::VARselect # or 
FIAR::ARorder # or 
causfinder::ARorderG # or 
causfinder::VARomlop (the last package is not free)

is to be run on variables in levels (not differenced).将在级别(无差异)中的变量上运行。

2 To check cointegration, use 2要检查协整,请使用

ca.jo(..,K=cointegrationLength)

Argument K in ca.jo controls the number of lags of VECM model. ca.jo 中的参数 K 控制 VECM 模型的滞后数。 Pass the number of lags found in VARomlop (or in others) as argument K. Determine the cointegration rank using ca.jo.将在 VARomlop(或其他)中找到的滞后数作为参数 K 传递。使用 ca.jo 确定协整等级。 ecdet option is "none" for no intercept in cointegration equation, "const" for constant term in cointegration equation and "trend" for trend variable in cointegration equation. ecdet 选项为“none”,表示协整方程中没有截距,“const”表示协整方程中的常数项,“trend”表示协整方程中的趋势变量。

Normalization of the long-run relationship are specified according to 1st column in mydata, which can be changed (if desired) via changing the columns of submitted mydata via, eg, mydata[,"X2","X1","X3","X4"].长期关系的规范化是根据 mydata 中的第一列指定的,可以通过更改提交的 mydata 的列来更改(如果需要),例如 mydata[,"X2","X1","X3", “X4”]。

K is the number of lags for the VAR in levels, so K - 1 is the number of lags in the VECM representation. K 是级别中 VAR 的滞后数,因此 K - 1 是 VECM 表示中的滞后数。 eg,例如,

summary(ca.jo(mydata, ecdet="none", type="eigen", K=29))

Based on the results of eigen/trace test, determine the existence of cointegration, and cointegration rank r.根据特征/迹检验的结果,确定协整的存在性,协整秩为r。

3 If cointegration is detected above among the series in the system, fit a vector error correction model (VECM) by taking the cointegration rank into account. 3如果在系统中的序列之间检测到上述协整,则通过考虑协整秩来拟合向量误差校正模型(VECM)。 ie, we are fitting a VECM model using the ca.jo's cointegration vectors in above step.即,我们在上述步骤中使用 ca.jo 的协整向量拟合 VECM 模型。 The result of ca.jo and the number of cointegration vectors are passed to cajorls. ca.jo 的结果和协整向量的数量被传递给 cajorls。 cajorls has the argument r (cointegration rank). cajorls 有参数 r(协整等级)。

A normalized cointegration vector is produced by estimating a restricted VECM with the command cajorls().通过使用命令 cajorls() 估计受限制的 VECM 来生成归一化协整向量。 eg,例如,

cajorls(...,K=lagLength)
cajorls(ca.jo(mydata, ecdet="none", type="eigen", K=29),r=1)

The error correction term may be included in each equation of the VECM only once.纠错项可以只包含在 VECM 的每个方程中一次。 It is either lagged by 1 or by p where p is the lag order of the VECM;它要么滞后 1 要么滞后 p,其中 p 是 VECM 的滞后阶数; the corresponding representations of the VECM are known as long-run and transitory; VECM 的相应表示被称为长期和暂时的; it is still the same model, just different representations;它仍然是相同的模型,只是不同的表示; we pick the one we like.我们选择我们喜欢的那个。

4 To convert VECM to VAR: 4将 VECM 转换为 VAR:

vars::vec2var

Analyze:分析:
http://www.r-bloggers.com/cointegration-r-irish-mortgage-debt-and-property-prices/ that answers your questions as well. http://www.r-bloggers.com/cointegration-r-irish-mortgage-debt-and-property-prices/也可以回答您的问题。

If you have a 2-variable VAR system, remain in classical G-causality.如果您有一个 2 变量 VAR 系统,请保持经典 G 因果关系。 If you have a ">2"-variable VAR system, you must go to advanced G-causality: Conditional G-causality, Partial G-causality, Harmonic G-causality, Canonical G-causality, Global G-causality etc.如果您有一个 ">2" 变量 VAR 系统,则必须使用高级 G-因果关系:条件 G-因果关系、部分 G-因果关系、谐波 G-因果关系、规范 G-因果关系、全局 G-因果关系等。

You may study the following papers as well:你也可以学习以下论文:

  1. "Causfinder: An R package for Systemwise Analysis of Conditional and Partial Granger Causalities", International Journal of Science and Advanced Technology, October 2014. http://www.ijsat.com/view.php?id=2014:October:Volume%204%20Issue%2010 “Causfinder的:R包条件和部分格兰杰因果关系的Systemwise分析”,国际科学期刊和先进技术,2014年10月http://www.ijsat.com/view.php?id=2014:October:Volume% 204%20期%2010

  2. "Determinants of Current Account Deficit in Turkey: The Conditional and Partial Granger Causality Approach" (Extended; 33 pages) https://www.academia.edu/17698799/Determinants_of_Current_Account_Deficit_in_Turkey_The_Conditional_and_Partial_Granger_Causality_Approach_Extended_ “土耳其经常账户赤字的决定因素:有条件和部分格兰杰因果关系方法”(扩展;33 页) https://www.academia.edu/17698799/Determinants_of_Current_Account_Deficit_in_Turkey_The_Conditional_and_Partial_Granger_Caustality

"Determinants of Current Account Deficit in Turkey: The Conditional and Partial Granger Causality Approach" (9 pages), Procedia Economics and Finance, Vol. “土耳其经常账户赤字的决定因素:有条件和部分格兰杰因果关系方法”(9 页),Procedia 经济学和金融,卷。 26, 2015, p.92-100 https://www.academia.edu/17057780/Determinants_of_Current_Account_Deficit_in_Turkey_The_Conditional_and_Partial_Granger_Causality_Approach 26, 2015, p.92-100 https://www.academia.edu/17057780/Determinants_of_Current_Account_Deficit_in_Turkey_The_Conditional_and_Partial_Granger_Causality_Approach

causfinder is a GENERALIZATION of FIAR package (You can find FIAR in CRAN archieve. FIAR 0.3, 0.4 and 0.5. FIAR is totally free). causfinder 是 FIAR 包的通用化(您可以在 CRAN archieve 中找到 FIAR。FIAR 0.3、0.4 和 0.5。FIAR 是完全免费的)。 https://cran.r-project.org/src/contrib/Archive/FIAR I highly suggest FIAR 0.3 since 0.3 version is clearly more and more extendable than the later versions. https://cran.r-project.org/src/contrib/Archive/FIAR我强烈建议使用 FIAR 0.3,因为 0.3 版本显然比以后的版本更具可扩展性。 Even you do not need to analyze 0.4 and 0.5 version.甚至不需要分析 0.4 和 0.5 版本。 Hence, I constructed causfinder over FIAR 0.3.因此,我在 FIAR 0.3 上构建了 causfinder。

In FIAR, you find the CGCs one by one.在 FIAR 中,您可以一一找到 CGC。 In causfinder, it gives ALL the CGCs systemwisely and at once.在 causfinder 中,它一次系统地给出所有 CGC。 In 6-variable system, there are 6*5=30 CGC and 30 PGC.在6变量系统中,有6*5=30个CGC和30个PGC。 These 30+30=60 CGCs and PGCs are calculated one by one in FIAR (60 commands).这30+30=60个CGC和PGC是在FIAR(60条命令)中一一计算的。 In causfinder, these 30+30 GCs are calculated with only 2 commands.在 causfinder 中,这 30+30 次 GC 仅用 2 个命令计算。 In 5-variable system, there are 5*4=20 CGC and 20 PGC.在5变量系统中,有5*4=20个CGC和20个PGC。 These 20+20=40 CGCs and PGCs are calculated one by one in FIAR (40 commands).这20+20=40个CGC和PGC是在FIAR(40条命令)中一一计算的。 In causfinder, these 20+20 GCs are calculated with only 2 commands.在 causfinder 中,这 20+20 次 GC 仅用 2 个命令计算。

What causfinder provides (over FIAR) is extreme speed/pace, simplicity, visualization, and ease of analysis; causfinder 提供的(在 FIAR 上)是极快的速度/速度、简单性、可视化和易于分析; nothing else.没有其他的。

If you wanna study CGC or PGC, you can do it via FIAR as well: Journal of Statistical Software (JSS): https://www.jstatsoft.org/article/view/v044i13 FIAR: An R Package for Analyzing Functional Integration in the Brain如果你想学习 CGC 或 PGC,你也可以通过 FIAR 来完成:Journal of Statistical Software (JSS): https://www.jstatsoft.org/article/view/v044i13 FIAR: An R Package for Analyzing Functional Integration in大脑

Note that:注意:

In R:在 R 中:

The packages that can perform CGC and PGC analysis: FIAR and causfinder可以执行 CGC 和 PGC 分析的软件包:FIAR 和 causfinder

In Matlab:在 Matlab 中:

The packages that can perform CGC and PGC analysis:可以执行 CGC 和 PGC 分析的软件包:

GCCA (Granger Causal Connectivity Analysis) (Anil SETH) 2009: GCCA(格兰杰因果连接分析)(Anil SETH)2009:
MVGC (Multivariate Granger Causality) 2014: New version of GCCA MVGC(Multivariate Granger Causality)2014:新版GCCA
GrangerCausalityGUI (the resultant work of Jianfeng FENG group that was developed in accompany of some papers through 2008-2013. GrangerCausalityGUI(冯建峰小组在2008-2013年期间与一些论文一起开发的成果。

In 2011, Roelstraete and Rosseel's FIAR R package that handles advanced G-causality analysis revealed a bug in GCCA! 2011 年,Roelstraete 和 Rosseel 处理高级 G 因果关系分析的 FIAR R 包揭示了 GCCA 中的一个错误!

To my knowledge, in other statistical/econometric softwares, there is no package/function that can perform CGC and PGC.据我所知,在其他统计/计量经济学软件中,没有可以执行 CGC 和 PGC 的包/函数。
Programming in Matlab is definitely more difficult than it is in R. Hence, I wrote causfinder in R (after I experience the coding in Gretl and Eviews.).在 Matlab 中编程肯定比在 R 中更难。因此,我在 R 中编写了 causfinder(在我体验了 Gretl 和 Eviews 中的编码之后。)。 (We think therefore we R!) (我们思故我们R!)

5 After you obtained VAR (from VECM) in which restriction caused by the cointegration is loaded on the coefficients of VAR; 5在您获得 VAR(来自 VECM)后,其中由协整引起的限制加载到 VAR 的系数上; (do the following if you have ">2"-variable system in Step 0. If not, there are already classical G-causality packages in R; use them) (如果您在第 0 步有 ">2" 变量系统,请执行以下操作。如果没有,则 R 中已经有经典的 G-因果关系包;使用它们)

FIAR::condGranger
FIAR::partGranger

or或者

causfinder::conditionalGgFp
causfinder::partialGgFp

If you want bootstrapping as well, then:如果你也想要引导,那么:

causfinder::conditionalGblup
causfinder::partialGblup

您可以在 R 中使用 Toda-Yamamoto 方法Toda-Yamamoto 实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM