R中线性回归截距的置信区间

The confidence interval by the intercept with linear regression in R

假设我有两个变量 weightage,我必须在这种情况下找到 99% 水平的置信区间:

  1. 通过纵坐标(Y 轴),如果我们进行线性回归 a=lm(weight~age)

我知道纵坐标直接是截距但是为什么这行不通:

predict(a, newdata=data.frame(age=intercept), interval='confidence',
level=0.99)

为什么这是不正确的?我想知道这些情况下的正确命令。

broom 包可以 return 回归模型估计的置信区间。

require(broom)
A <- c(12,11,12,15,13,16,13,18,11,14)
B <- c(50,51,62,45,63,76,53,68,51,74)

model <- lm(A~B)

tidy(model, conf.int = TRUE, conf.level = 0.99)
         term  estimate  std.error statistic   p.value    conf.low conf.high
1 (Intercept) 6.8153948 3.75608761  1.814493 0.1071515 -5.78773401 19.418524
2           B 0.1127252 0.06240674  1.806299 0.1085031 -0.09667358  0.322124

编辑: 我忘记了可以在 base R 中获得回归模型的置信区间。

confint(model, level = .99)
                  0.5 %    99.5 %
(Intercept) -5.78773401 19.418524
B           -0.09667358  0.322124