|
x <- rnorm(15)
y <- x + rnorm(15)
predict(lm(y ~ x))
new <- data.frame(x = seq(-3, 3, 0.5))
predict(lm(y ~ x), new, se.fit = TRUE)
pred.w.plim <- predict(lm(y ~ x), new, interval = "prediction")#拟合值置信区间
matplot(new$x, pred.w.plim,lty = c(1,2,2), type = "l", ylab = "predicted y")
pred.w.clim <- predict(lm(y ~ x), new, interval = "confidence")#观测值置信区间
matplot(new$x, pred.w.clim, lty = c(1,2,2), type = "l", ylab = "predicted y")
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-24 09:53
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社