r - R 密度误差 bw.SJ

标签 r density-plot

我在 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() and bw.SJ() now avoid integer overflow for large sample sizes.

关于r - R 密度误差 bw.SJ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36227614/

相关文章:

r - 更改随机选择的 data.table 子集的值

r - 在 R 中的密度图(ggplot2)的 x 轴上显示显式点

python - 如何制作大型二维散点图的等高线/密度图

用一些空字符串重新编码字符向量

R读取excel文件数值精度问题

r - 如何做一个荒谬的情节

r - 如何标记 r 列中两个特定字符值之间的所有行?

Matlab 二维密度图

r - ggplot2 stat_密度_2d 分组时无法正常工作

r - 如何调整 y 轴而不弄乱 r 中多个直方图的 x 轴?