【发布时间】:2014-05-26 06:11:47
【问题描述】:
我有两个向量:1) ~1000 个样本均值和 2) 这些均值对应的 ~1000 个标准差。我想创建这些数据的核密度图,使用样本均值作为估计密度的观测值,并将每个均值的标准差作为每个观测值的带宽。问题是,密度只允许将长度为 1 的向量用作带宽。例如:
plot(density(means,bw=error))
返回以下警告:
1: In if (!is.finite(bw)) stop("non-finite 'bw'") :
the condition has length > 1 and only the first element will be used
2: In if (bw <= 0) stop("'bw' is not positive.") :
the condition has length > 1 and only the first element will be used
3: In if (!is.finite(from)) stop("non-finite 'from'") :
the condition has length > 1 and only the first element will be used
4: In if (!is.finite(to)) stop("non-finite 'to'") :
the condition has length > 1 and only the first element will be used
...我得到一个图,它使用列表中第一项的错误作为我所有观察的带宽。
关于如何为用于生成核密度图的每个观察值实现单独的用户定义带宽有什么想法吗?
【问题讨论】:
标签: r bandwidth kernel-density