[英]How to bootstrap a linear regression and estimate confidence intervals in R?
[英]How to work with linear regression and confidence intervals in R?
我想知道R中使用的命令来处理线性回归问题和置信区间,以及为什么这些不正确。
例如,假设我们有以下数据:
A <- c(12,11,12,15,13,16,13,18,11,14) # this is the width
B <- c(50,51,62,45,63,76,53,68,51,74) # this is the height
我们做了一个线性回归,用变量A(宽度)描述变量B(高度)。 问题是找到90%置信区间,其中高度(B)的平均值为14(宽度(A))。
我知道如何在R, lm(B~A)
进行线性回归,我得到一个像这样的方程式B = a + A * c ,其中B和A是我的变量a是截距..
我试过的是:
B= a + (14)*c
= MU(例如) t.test(B, mu = MU, conf.level=0.9)
,但不幸的是它不正确.. 试试这个:
> m <- lm(B~A)
> predict(m, newdata=data.frame(A=14), interval='confidence', level=0.9)
fit lwr upr
1 60.58495 54.72854 66.44135
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.