简体   繁体   English

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

[英]The confidence interval by the intercept with linear regression in R

Let's say that i have two variables weight and age , i have to find the confidence interval with level 99% by this case: 假设我有两个变量weightage ,在这种情况下,我必须找到99%的置信区间:

  1. By the ordinate (Y-Axis), if we did a linear regression a=lm(weight~age) 通过纵坐标(Y轴),如果我们进行线性回归,则a=lm(weight~age)

I know that the ordinate is directly the intercept but why this won't work: 我知道纵坐标是截距,但是为什么这样不起作用:

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

Why this is incorrect? 为什么这是不正确的? I would like to know the correct commands for these cases. 我想知道这些情况下的正确命令。

The broom package can return confidence intervals for regression model estimates. 扫帚包装可以返回置信区间,以进行回归模型估计。

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

EDIT: I forgot that one can get confidence intervals for regression models in base R. 编辑:我忘记了可以在基数R中获得回归模型的置信区间。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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