Joe Byers
2006-Oct-10 16:40 UTC
[R] .arch.uni in function call in arch test of vars package
I have been reviewing the arch test of vars package that is based on Engle's paper. R-metrics has this as a wants/todo item. I need an arch test and thought I might accomplish two things at once or at least try. The arch test requires a varest object and I am trying to write one that will use R-metrics arima, arch, Garch objects, or at least a vector. Also the arch function has the following line of code that I can not find the function anywhere archs.resids <- apply(resids, 2, function(x) .arch.uni(x, lags.single = lags.single)) does any one know about the function .arch.uni? Thank you Joe
Pfaff, Bernhard Dr.
2006-Oct-11 07:57 UTC
[R] .arch.uni in function call in arch test of vars package
>The arch test requires a varest object and I am trying to >write one that >will use R-metrics arima, arch, Garch objects, or at least a vector. >Also the arch function has the following line of code that I can not >find the function anywhere > > archs.resids <- apply(resids, 2, function(x) .arch.uni(x, > lags.single = lags.single)) >Hello Joe, have a look at the source code (internal.R). For your convenience the function is: ## univariate ARCH test ".arch.uni" <- function(x, lags.single){ lags.single <- lags.single + 1 mat <- embed(scale(x)^2, lags.single) arch.lm <- summary(lm(mat[, 1] ~ mat[, -1])) STATISTIC <- arch.lm$r.squared*length(resid(arch.lm)) names(STATISTIC) <- "Chi^2" PARAMETER <- lags.single - 1 names(PARAMETER) <- "df" PVAL <- 1 - pchisq(STATISTIC, df = PARAMETER) METHOD <- "ARCH test (univariate)" result <- list(statistic = STATISTIC, parameter = PARAMETER, p.value PVAL, method = METHOD, data.name = deparse(substitute(x))) class(result) <- "htest" return(result) } Best, Bernhard>does any one know about the function .arch.uni? > >Thank you >Joe > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. >***************************************************************** Confidentiality Note: The information contained in this mess...{{dropped}}