我在 SJ 方法中使用密度函数:
rdat <- rnorm(111111)
density(rdat, bw = "sj")
Error in bw.SJ(x, method = "ste") : sample is too sparse to find TD
它似乎在大样本上失败,说明样本太稀疏。之前问过这个问题here ,但自 2008 年以来有什么变化吗?是否有针对此/解决方法的任何修复?
编辑:限制似乎是
46341
最佳答案
此错误已在 R 3.4.0(2017 年 4 月)中修复。
这是来自 svnlog 的相关片段:
r71965 | maechler | 2017-01-13 04:30:18 -0600 (Fri, 13 Jan 2017) | 1 line
Changed paths:
M /trunk/doc/NEWS.Rd
M /trunk/src/library/stats/R/bandwidths.R
M /trunk/src/library/stats/man/bandwidth.Rd
M /trunk/src/library/stats/man/density.Rd
M /trunk/src/library/stats/src/bandwidths.c
fix bw.SJ() integer overflow for large n
这是R源代码镜像中的相应提交:https://github.com/wch/r-source/commit/5af0f7200128315392cf813127a654153b5e7739
这是来自 R 3.4.0 change log 的片段:
Bandwidth selectors
bw.ucv()
,bw.bcv()
andbw.SJ()
now avoid integer overflow for large sample sizes.
关于r - R 密度误差 bw.SJ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36227614/