![](/img/trans.png)
[英]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.