【发布时间】:2017-06-24 12:54:26
【问题描述】:
我想获取 loess 函数中每个观察值的置信区间的上限和下限,以复制 ggplot 在 geom_smooth() 中所做的事情
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = hp)) +
geom_point() +
geom_smooth(method = 'loess')
我知道我可以从线性模型中获得上限和下限,但这不适用于 loess:
lm_mod <- lm(hp ~ mpg, mtcars)
predict(lm_mod, mtcars, interval="confidence", level=0.95)
loess_mod <- loess(hp ~ mpg, mtcars)
predict(loess_mod, mtcars, interval="confidence", level=0.95)
【问题讨论】:
标签: r ggplot2 machine-learning