ARCH.Quantile.Lags <- function(y, tau=.01, p=1, r=3) { ################################################################################ # # # ARCH.Quantile.Lags Function by Breno de Andrade Pinheiro Néri # # # # brenoneri@gmail.com www.fgv.br/aluno/bneri # # # # Septembre, 2005 - Version 1 # # # ################################################################################ # # # This code tests the significance of the estimated coefficients in the ARCH # # Quantile specification. # # # # You enter a time series (y), a quantile (tau), the number of lags (p) for # # the ols regression that estimates the conditional mean, and the maximum # # number of lags in the ARCH specification (r). # # # # The code returns a vector of p-values of the significance test of the ARCH # # coefficients. For a joint teste, see Lima and Néri (2005). # # # # Defaults: tau=.01, p=1 and r=3. # # # ################################################################################ # # # You may use this code only if you accept the conditions: # # (1) I am not liable for any problem caused by this code (i.e. you use it at # # your own risk); # # (2) You must give me credit in your papers where this code has been used. # # # ################################################################################ t <- length(y) library(quantreg) y.lag <- array(0, c(t-p, p)) for(i in 1:p) y.lag[,i] <- y[(p+1-i):(t-i)] e <- residuals(lm(y[(p+1):t]~y.lag)) J <- 0 suppressWarnings(for(i in r:1) { e.lag <- array(0, c(t-p-i, i)) for(j in 1:i) e.lag[,j] <- e[(i+1-j):(t-p-j)] reg <- summary(rq(e[(i+1):(t-p)]~abs(e.lag), tau), se="nid") J[i] <- reg$coef[[i+1]]^2/reg$cov[i+1,i+1] }) P <- array(1-pchisq(J, 1)) dimnames(P) <- list(paste("gamma", 1:r, sep="")) return(P) }