Created
November 18, 2012 04:28
-
-
Save mattbaggott/4103536 to your computer and use it in GitHub Desktop.
Engle's AutoRegressive Conditional Heteroskedasticity (ARCH) estimator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arch_test <- function (x, order=10){ | |
# AutoRegressive Conditional Heteroskedasticity (ARCH) estimator | |
xsq <- x^2 | |
nobs <- length(x) | |
inds <- outer(0:(nobs - order - 1), order:1, "+") | |
xmat <- xsq[inds] | |
dim(xmat) <- dim(inds) | |
xreg <- lm(xsq[-1:-order] ~ xmat) | |
summary(xreg)$r.squared * (nobs - order) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment