小编Mar*_*ler的帖子

浮点错误 fligner.test r 函数?

我注意到,使用fligner.testrstats包中的统计测试通过简单的转换提供了不同的结果,即使情况不应该如此。

这是一个例子(原始数据集的差异更加显着):

g  <- factor(rep(1:2, each=6))
x1 <- c(2,2,6,6,1,4,5,3,5,6,5,5)
x2 <- (x1-1)/5 #> cor(x1,x2) [1] 1
fligner.test(x1,g) # chi-squared = 4.2794, df = 1, p-value = 0.03858
fligner.test(x2,g) # chi-squared = 4.8148, df = 1, p-value = 0.02822
Run Code Online (Sandbox Code Playgroud)

查看函数代码,我注意到中位数居中可能导致问题:

x1 <- x1 - tapply(x1,g,median)[g]
x2 <- x2 - tapply(x2,g,median)[g]
unique(abs(x1)) # 1 3 2 0
unique(abs(x2)) # 0.2 0.6 0.4 0.2 0.0 <- repeated 0.2
Run Code Online (Sandbox Code Playgroud)

这是一个已知问题吗?应如何解决这种不一致?

floating-point precision r floating-accuracy

6
推荐指数
1
解决办法
67
查看次数

标签 统计

floating-accuracy ×1

floating-point ×1

precision ×1

r ×1