- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 18 个
- 通用积分
- 7.1646
- 学术水平
- 6 点
- 热心指数
- 6 点
- 信用等级
- 6 点
- 经验
- 183 点
- 帖子
- 11
- 精华
- 0
- 在线时间
- 23 小时
- 注册时间
- 2018-11-19
- 最后登录
- 2021-2-19
|
复制粘贴这段代码:
- ArchTest <- function (x, lags=12,
- demean = FALSE)
- {
- # Capture name of x for documentation in the output
- xName <- deparse(substitute(x))
- #
- x <- as.vector(x)
- if(demean) x <- scale(x, center = TRUE, scale = FALSE)
- #
- lags <- lags + 1
- mat <- stats::embed(x^2, lags)
- arch.lm <- summary(stats::lm(
- mat[, 1] ~ mat[, -1]))
- STATISTIC <- arch.lm$r.squared *
- length(stats::resid(arch.lm))
- names(STATISTIC) <- "Chi-squared"
- PARAMETER <- lags - 1
- names(PARAMETER) <- "df"
- PVAL <- stats::pchisq(STATISTIC,
- df = PARAMETER, lower.tail=FALSE)
- METHOD <- paste("ARCH LM-test; ",
- "Null hypothesis: no ARCH effects")
- result <- list(statistic = STATISTIC,
- parameter = PARAMETER,
- p.value = PVAL, method = METHOD,
- data.name = xName)
- class(result) <- "htest"
- return(result)
- }
复制代码
|
|