[英]How are the “plot.gam” confidence intervals calculated?
If a model is fitted using mgcv
and then the smooth terms are plotted, 如果使用mgcv
拟合模型,然后绘制平滑项,
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
? 为了使用标准误差和乘数2提取下限和上限,但是当我绘制它时,它看起来与plot.gam
绘制的置信区间有些不同。
So, how are those calculated? 那么,这些是如何计算的呢?
I do not use seWithMean = true
or anything like that. 我不使用seWithMean = true
或类似的东西。
It is 1 standard deviation. 它是1个标准差。
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.