codes of vecm model with p-values and standard error

679 views Asked by At

I have run the VECM model and have only got the coefficients values. how I can get the p - values and the standard error in the same results

1

There are 1 answers

0
Erdogan CEVHER On

To my knowledge, the answer is:

library(urca)   

The followings are deg. of freedom non-adjusted:

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))

The followings are deg. of freedom adjusted:

V1.eigen <- ca.jo(finland, ecdet="none", type="eigen", K=2) # rank=1
vecm <- cajorls(V1.eigen, r=1)
beta <- V1.eigen@V[,1] 
alfa <- V1.eigen@W[,1] 
residuals <- resid(vecm$rlm)
N <- nrow(residuals)
sigma <- crossprod(residuals)/N     
beta.se <- sqrt(diag(kronecker(solve(crossprod(V1.eigen@RK[,-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

Inspiring from here, one may suggest (for a neat presentation):

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(cajo_o@RK[, -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))