【问题标题】:Confidence Interval from LOESS dissapears when using weights with geom_smooth command使用 geom_smooth 命令的权重时,来自 LOESS 的置信区间消失
【发布时间】:2017-09-12 12:38:49
【问题描述】:

在 R 中,使用 ggplot2 包,我有以下两行:

ggplot(data, aes(x = x, y = Pinera)) + 
    geom_point(shape = 1) + 
    geom_smooth(method = loess, se = TRUE)

ggplot(data, aes(x = x, y = Pinera, weight = pesos)) + 
    geom_point(shape = 1) + 
    geom_smooth(method = loess, se = TRUE)

第一个为我的数据提供了一条带有阴影置信区间的未加权平滑曲线,但是当我添加权重时,尽管我声明了 se = TRUE,但置信区间区域消失了。

这是我的data

【问题讨论】:

  • 您的数据似乎没有比索变量
  • 我在代码中使用 x 在本地创建了比索变量。我已经发现了问题:当创建“比索”时,一些权重被四舍五入为 0,这在模型中是不被接受的。通过对每个重量施加至少一个 epsilon,它就可以正常工作。

标签: r ggplot2 loess


【解决方案1】:

问题已解决:loess 无法处理带零的权重向量。

【讨论】:

    猜你喜欢
    • 2016-10-25
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    • 1970-01-01
    • 2016-09-26
    • 2013-10-09
    • 2018-01-26
    相关资源
    最近更新 更多