代码之家  ›  专栏  ›  技术社区  ›  LulY

geom_smooth()中的“秩不足拟合的预测可能会产生误导”

  •  0
  • LulY  · 技术社区  · 4 年前

    我使用绘制数据 ggplot2 并获取错误 "prediction from a rank-deficient fit may be misleading" 。请参见此处:

    # Data.
    temp <- structure(list(x = c(-62135599651, -62135599057, -62135598463,  -62135597869, -62135597275, -62135596681, -62135596087, -62135595493,  -62135594899, -62135594305), y = c(0.1, 0.2, 0.4, 0.3, 0.5, 0.5,  0.9, 0.9, 0.8, 1)), class = "data.frame", row.names = c(NA, -10L))
    # Plot.
    ggplot(temp, aes(x, y)) +
      geom_point() +
      geom_smooth(method= "lm")
    

    这个 geom_smooth() 图中的线看起来不对(正如错误所示):

    Plot

    有一个 similiar question 但它缺乏一个可重复的例子,也没有答案。我在这里能做什么?

    编辑

    对于那些想进一步了解如何在统计上解决问题的人,请参阅我的问题 here 。

    0 回复  |  直到 4 年前
        1
  •  3
  •   Waldi    4 年前

    您遇到了一个数值精度舍入问题。

    你可以居中 x 通过减法 mean(x) 。

    ggplot(temp, aes(x, y)) +
      geom_point() + 
      geom_smooth(method= "lm", formula = y ~ I(x-mean(x)))
    

    enter image description here