【问题标题】:R: Shapiro-Wilk TestR:夏皮罗-威尔克测试
【发布时间】:2017-03-19 15:35:23
【问题描述】:

我正在使用 Shapiro-Wilk 检验来拒绝正态性的原假设。

我正在使用来自 Yahoo 的代码。例如,对于标准普尔 500:

SP500 = get.hist.quote(instrument = '^GSPC',
        start="2001-01-01",  end = "2015-12-31",
        quote = c("AdjClose"),provider = "yahoo",
        compress = "d") 
rSP500 = diff(log(SP500)

我在尝试运行 Shapiro-Wilk 测试时遇到错误。

例如,

> SWTestSP500 = shapiro.test(rSP500[(3000-499):3000])
Error in if (rng == 0) stop("all 'x' values are identical") : 
  argument is of length zero

我上网的唯一搜索是它与输入不是数字有关,但我相当肯定 rSP500 都是数字。

有人可以建议吗?谢谢!

【问题讨论】:

    标签: r statistics


    【解决方案1】:

    多次阅读R文档后,我尝试了

    SWTestSP500 = shapiro.test(as.vector(rSP500[(3000-499):3000]))

    它终于奏效了。原来 shapiro.test() strictly 接受向量。

    【讨论】:

      猜你喜欢
      • 2020-03-11
      • 2012-06-06
      • 2021-10-22
      • 2017-05-20
      • 1970-01-01
      • 2023-03-30
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多