gpt4 book ai didi

r - ks.test 和 ties 的问题

转载 作者:行者123 更新时间:2023-12-03 20:03:06 28 4
gpt4 key购买 nike

我有一个发行版,例如:

d 
#[1] 4 22 15 5 9 5 11 15 21 14 14 23 6 9 17 2 7 10 4

或者,向量 ddput格式。
d <- c(4, 22, 15, 5, 9, 5, 11, 15, 21, 14, 14, 23, 6, 9, 17, 2, 7, 10, 4)

当我应用 ks.test 时:
gamma <- ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) 

这给出了以下警告:

Warning message: In ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) : ties should not be present for the Kolmogorov-Smirnov test



我试过放 unique(d) ,但很明显我的数据减少了值,我不希望这种情况发生。
和网上的其他方式和例子一样,这个例子也发生了,但不同的是测试显示了一些带有警告消息的结果,而不仅仅是没有 ks.test值的消息。 .

一些帮助?

最佳答案

gamma你可以找到你的结果,警告信息没有被阻止

d <- c(4, 22, 15, 5, 9, 5, 11, 15, 21, 14, 14, 23, 6, 9, 17, 2, 7, 10, 4)
gamma <- ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563)

Warning message: In ks.test(d, "pgamma", shape = 3.178882, scale = 3.526563) : ties should not be present for the Kolmogorov-Smirnov test


gamma

One-sample Kolmogorov-Smirnov test

data: d
D = 0.14549, p-value = 0.816
alternative hypothesis: two-sided

您可以在帮助页面 ??ks.test 中找到对警告的解释。

The presence of ties always generates a warning, since continuous distributions do not generate them. If the ties arose from rounding the tests may be approximately valid, but even modest amounts of rounding can have a significant effect on the calculated statistic.



正如您所看到的,应用了一些四舍五入,并且测试“大致”有效。

关于r - ks.test 和 ties 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51987605/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com