I didn\'t find any satisfactory answer to the confidence intervals (CIs) for LOWESS regression line of the \'stats\' package of R:
plot(cars, main = \"lowess(car
You can do this with predict()
and loess()
. lowess
is older than loess
and has fewer features, though it is a bit faster. But in this context, I'd use loess
as follows.
plot(cars)
plx<-predict(loess(cars$dist ~ cars$speed), se=T)
lines(cars$speed,plx$fit)
lines(cars$speed,plx$fit - qt(0.975,plx$df)*plx$se, lty=2)
lines(cars$speed,plx$fit + qt(0.975,plx$df)*plx$se, lty=2)