简体   繁体   中英

How are the “plot.gam” confidence intervals calculated?

If a model is fitted using mgcv and then the smooth terms are plotted,

m <- gam(y ~ s(x))
plot(m, shade = TRUE)

then you get a plot of the curve with a confidence interval. These are, I presume, pointwise-confidence intervals. How are they computed?

I tried to write

object <- plot(m, shade = true)
object[[1]]$fit +- 2*object[[1]]$se

in order to extract the lower and upper bounds using the standard errors and a multiplier of 2, but when I plot it, it looks a bit different than the confidence intervals plotted by plot.gam ?

So, how are those calculated?

I do not use seWithMean = true or anything like that.

It is 1 standard deviation.

oo <- plot.gam(m)
oo <- oo[[1]]
points(oo$x, oo$fit, pch = 20)
points(oo$x, oo$fit - oo$se, pch = 20)

Reproducible example:

x <- seq(0, 2 * pi, length = 100)
y <- x * sin(x) + rnorm(100, 0, 0.5)
m <- gam(y ~ s(x))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM