我试图找出在R中执行Shapiro-Wilk正态性测试时究竟如何计算测试统计量。这是函数的主体。
> shapiro.test
function (x)
{
DNAME <- deparse(substitute(x))
stopifnot(is.numeric(x))
x <- sort(x[complete.cases(x)])
n <- length(x)
if (is.na(n) || n < 3L || n > 5000L)
stop("sample size must be between 3 and 5000")
rng <- x[n] - x[1L]
if (rng == 0)
stop("all 'x' values are identical")
if (rng < 1e-10)
x <- x/rng
res <- .Call(C_SWilk, x)
RVAL <- list(statistic = c(W = res[1]), p.value = res[2],
method = "Shapiro-Wilk normality test", data.name = DNAME)
class(RVAL) <- "htest"
return(RVAL)
}
<bytecode: 0x0603f2a8>
<environment: namespace:stats>
我无法理解这一部分:
.Call(C_SWilk, x)
似乎调用了一个函数(即C_SWilk)。有谁知道这个功能是什么?我试着看,但它给了我一个错误,
> C_SWilk
Error: object 'C_SWilk' not found