0
我已經運行VECM模型並且只有係數值。我怎樣才能在p - 值和標準差在相同的結果具有p值和標準誤差的vecm模型的代碼
我已經運行VECM模型並且只有係數值。我怎樣才能在p - 值和標準差在相同的結果具有p值和標準誤差的vecm模型的代碼
據我所知,答案是:
library(urca)
以下爲度。未經調整的自由度:
coeftest(cajorls(ca.jo(finland, ecdet="none", type="eigen", K=2),r=1)$rlm)
coef(summary(cajorls(ca.jo(finland, ecdet="none", type="eigen", K=2), r=1)$rlm))
以下是deg。自由的調整:
V1.eigen <- ca.jo(finland, ecdet="none", type="eigen", K=2) # rank=1
vecm <- cajorls(V1.eigen, r=1)
beta <- [email protected][,1]
alfa <- [email protected][,1]
residuals <- resid(vecm$rlm)
N <- nrow(residuals)
sigma <- crossprod(residuals)/N
beta.se <- sqrt(diag(kronecker(solve(crossprod([email protected][,-1])), solve(t(alfa)%*%solve(sigma) %*% alfa))))
beta.t <- c(NA, beta[-1]/beta.se) # deg.of freedom adjusted
names(beta.t) <- rownames(cajorls(ca.jo(finland, ecdet="none", type="eigen", K=2), r=1)$beta)
beta.t
beta.pval <- dt(beta.t, df=vecm$rlm$df.residual)
beta.pval
從here鼓舞人心的,可以建議(對於一個整潔的演示):
library(texreg)
cajo_beta_create <- function(cajo_o, cajorls_o) {
alfa <- coef(cajorls_o$rlm)[1, ]
residuals <- resid(cajorls_o$rlm)
N <- nrow(residuals)
sigma <- crossprod(residuals)/N
beta <- cajorls_o$beta
# standard errors
beta.se <- sqrt(diag(kronecker(solve(crossprod([email protected][, -1])), solve(t(alfa) %*% solve(sigma) %*% alfa))))
beta.se2 <- c(NA, beta.se)
beta.t <- c(NA, beta[-1]/beta.se)
beta.pvalue <- dt(beta.t, df=cajorls_o$rlm$df.residual) # p values
tr <- createTexreg(coef.names = as.character(rownames(beta)), coef = as.numeric(beta), se = beta.se2, pvalues=beta.pvalue,
gof.names = c('Dummy'), gof=c(1), gof.decimal=c(FALSE))
return(tr)
}
cajo_beta_create(V1.eigen, vecm)
screenreg(cajo_beta_create(V1.eigen, vecm))