shapiro.test 中的错误:样本大小必须介于 [英] Error in shapiro.test : sample size must be between

查看:436
本文介绍了shapiro.test 中的错误:样本大小必须介于的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 R 中有一个向量,有 1521298 个点,必须对其进行正态性测试.我选择了 Shapiro-Wilk 测试,但 R 函数 shapiro.test() 说:

I have a vector, in R, with 1521298 points, which have to be tested for normality. I chose the Shapiro-Wilk test, but the R function shapiro.test() says:

shapiro.test(z_scores) 中的错误:样本大小必须在 3 到 5000 之间

Error in shapiro.test(z_scores) : sample size must be between 3 and 5000

您是否知道任何其他功能可以测试它或如何规避此问题?

Do you know any other function to test it or how to circumvent this issue?

推荐答案

使用超过 5.000 条记录无法完成 Shapiro 测试.

Shapiro test cannot done using more than 5.000 records.

您可以尝试仅使用前 5.000 个样本进行 shapiro 测试.如果它可以帮助您,请使用如下代码:

You can try to do the shapiro test using only the first 5.000 samples. IF it can help you, use the code like this:

shapiro.test(beaver2$temp[0:5000])

但请注意,测试将仅使用您数据的前 5.000 个样本.

But pay attention, the test will use only the first 5.000 samples of your data.

另一方面,如果您需要使用样本的所有记录,请使用另一个类似的检验,例如 Anderson-Darling 正态性检验.您也可以执行两者并进行比较,如下面的脚本:

In the other hand, if you need to use all the records of your sample, use another similar test, like Anderson-Darling normality test. You also can execute both and compare, like this script below:

# clean workspace
rm(list=ls())

# Install required packages:
install.packages('nortest')

#Model data tho use
ModelData = beaver2$temp

#Do shapiro test with only the first 5000 records
shapiro.test(ModelData[0:5000])$p.value

#Anderson-Darling normality test
library(nortest)
ad.test(ModelData)$p.value

这篇关于shapiro.test 中的错误:样本大小必须介于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆