夏皮罗威尔克测验

  • 本文关键字:夏皮罗 r
  • 更新时间 :
  • 英文 :


我正在努力完成Shapiro Wilks测试。

我在我的数据集上使用了这个函数:

shapiro.test(rdailypriceUSA500)
Shapiro-Wilk normality test
data:  rdailypriceUSA500
W = 0.85676, p-value < 2.2e-16

我的数据集由两列组成,日期和收盘日收益。

虽然测试函数已经生成了W &p值输出,我只是不确定我是否正确地执行了测试,因为我没有指定一列数据。

希望这对你有帮助。当在多列上运行函数时,我得到一个错误。只有当一个列被选中时,函数才会起作用。

> shapiro.test(mtcars[,1:3])
Error in shapiro.test(mtcars[, 1:3]) : is.numeric(x) is not TRUE

> shapiro.test(mtcars[,1])
Shapiro-Wilk normality test
data:  mtcars[, 1]
W = 0.94756, p-value = 0.1229

同样,如果你运行?shapiro.test,你可以看到函数的文档,而shapiro.test的代码:

function (x) 
{
DNAME <- deparse1(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: 0x0000017a65930318>
<environment: namespace:stats>

使用这些工具来调查问题是很好的做法。

最新更新