0
我想獲得在黃土功能各觀測置信區間的上限和下限複製什麼ggplot
確實在geom_smooth()
置信區間/帶的黃土複製geom_smooth
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = hp)) +
geom_point() +
geom_smooth(method = '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)