統(tǒng)計(jì)建模與R軟件第六章習(xí)題_第1頁
統(tǒng)計(jì)建模與R軟件第六章習(xí)題_第2頁
統(tǒng)計(jì)建模與R軟件第六章習(xí)題_第3頁
統(tǒng)計(jì)建模與R軟件第六章習(xí)題_第4頁
統(tǒng)計(jì)建模與R軟件第六章習(xí)題_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、第六章1 a> x <- c(5.1, 3.5, 7.1, 6.2, 8.8, 7.8, 4.5, 5.6, 8.0, 6.4)> y <- c(1907, 1287, 2700, 2373, 3260, 3000, 1947, 2273, 3113,2493)> plot(x,y)X與Y線性相關(guān) b> x <- c(5.1, 3.5, 7.1, 6.2, 8.8, 7.8, 4.5, 5.6, 8.0, 6.4)> y <- c(1907, 1287, 2700, 2373, 3260, 3000, 1947, 2273, 3113,24

2、93)> lm.sol<-lm(y1+x)> summary(lm.sol)Call:lm(formula = y 1 + x)Residuals: Min 1Q Median 3Q Max -128.591 -70.978 -3.727 49.263 167.228 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 140.95 125.11 1.127 0.293 x 364.18 19.26 18.908 6.33e-08 *-Signif. codes: 0 * 0.001 * 0.01

3、 * 0.05 . 0.1 1 Residual standard error: 96.42 on 8 degrees of freedomMultiple R-Squared: 0.9781, Adjusted R-squared: 0.9754 F-statistic: 357.5 on 1 and 8 DF, p-value: 6.33e-08 回歸方程為Y=140.95+364.18X,極為顯著 d> new <- data.frame(x=7)> lm.pred <- predict(lm.sol,new,interval="prediction&q

4、uot;,level=0.95)> lm.pred fit lwr upr1, 2690.227 2454.971 2925.484Y(7)= 2690.227, 2454.971,2925.4842> out<-data.frame(+ x1 <- c(0.4,0.4,3.1,0.6,4.7,1.7,9.4,10.1,11.6,12.6,10.9,23.1,23.1,21.6,23.1,1.9,26.8,29.9),+ x2 <- c(52,34,19,34,24,65,44,31,29,58,37,46,50,44,56,36,58,51),+ x3 <

5、- c(158,163,37,157,59,123,46,117,173,112,111,114,134,73,168,143,202,124),+ y <- c(64,60,71,61,54,77,81,93,93,51,76,96,77,93,95,54,168,99)+ )> lm.sol<-lm(yx1+x2+x3,data=out)> summary(lm.sol)Call:lm(formula = y x1 + x2 + x3, data = out)Residuals: Min 1Q Median 3Q Max -27.575 -11.160 -2.799

6、 11.574 48.808 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 44.9290 18.3408 2.450 0.02806 * x1 1.8033 0.5290 3.409 0.00424 *x2 -0.1337 0.4440 -0.301 0.76771 x3 0.1668 0.1141 1.462 0.16573 -Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 19.93 on 14 degree

7、s of freedomMultiple R-Squared: 0.551, Adjusted R-squared: 0.4547 F-statistic: 5.726 on 3 and 14 DF, p-value: 0.009004 回歸方程為 y=44.9290+1.8033x1-0.1337x2+0.1668x3由計(jì)算結(jié)果可以得到,回歸系數(shù)與回歸方程的檢驗(yàn)都是顯著的3 a> x<-c(1,1,1,1,2,2,2,3,3,3,4,4,4,5,6,6,6,7,7,7,8,8,8,9,11,12,12,12)> y<-c(0.6,1.6,0.5,1.2,2.0,1.3

8、,2.5,2.2,2.4,1.2,3.5,4.1,5.1,5.7,3.4,9.7,8.6,4.0,5.5,10.5,17.5,13.4,4.5,+ 30.4,12.4,13.4,26.2,7.4)> lm.sol <- lm(y 1+x)> summary(lm.sol)Call:lm(formula = y 1 + x)Residuals: Min 1Q Median 3Q Max -9.84130 -2.33691 -0.02137 1.05921 17.83201 Coefficients: Estimate Std. Error t value Pr(>|t|)

9、 (Intercept) -1.4519 1.8353 -0.791 0.436 x 1.5578 0.2807 5.549 7.93e-06 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 5.168 on 26 degrees of freedomMultiple R-Squared: 0.5422, Adjusted R-squared: 0.5246 F-statistic: 30.8 on 1 and 26 DF, p-value: 7.931e-06 線性回歸方程為 y=-1.451

10、9+1.5578x,并且未通過t檢驗(yàn)和F檢驗(yàn)> plot(x,y)> abline(-1.4519,1.5578)>c> x<-c(1,1,1,1,2,2,2,3,3,3,4,4,4,5,6,6,6,7,7,7,8,8,8,9,11,12,12,12)> y<-c(0.6,1.6,0.5,1.2,2.0,1.3,2.5,2.2,2.4,1.2,3.5,4.1,5.1,5.7,3.4,9.7,8.6,4.0,5.5,10.5,17.5,13.4,4.5,+ 30.4,12.4,13.4,26.2,7.4)> y.res<-resid(lm.s

11、ol);y.fit<-predict(lm.sol)> plot(y.resy.fit)> y.rst<-rstandard(lm.sol)> plot(y.rsty.fit)>普通殘差標(biāo)準(zhǔn)化殘差d(4)> lm.new<-update(lm.data3,sqrt(.).);coef(lm.new)(Intercept) x 0.7665018 0.2913620 > plot(x,y)> lines(x,y=0.5875222+0.08489065*x2+0.4466549*x)> y.res<-resid(lm.new

12、);y.fit<-predict(lm.new)> plot(y.resy.fit)> y.rst<-rstandard(lm.new)> plot(y.rsty.fit)4> lm.sol<-lm(YX1+X2,data=toothpaste)> summary(lm.sol)Call:lm(formula = Y X1 + X2, data = toothpaste)Residuals: Min 1Q Median 3Q Max -0.497785 -0.120312 -0.008672 0.110844 0.581059 Coefficie

13、nts: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.4075 0.7223 6.102 1.62e-06 *X1 1.5883 0.2994 5.304 1.35e-05 *X2 0.5635 0.1191 4.733 6.25e-05 *-Signif. codes: 0 * 0.001 * 0.01 * 0.05 . 0.1 1 Residual standard error: 0.2383 on 27 degrees of freedomMultiple R-squared: 0.886, Adjusted R-squar

14、ed: 0.8776 F-statistic: 105 on 2 and 27 DF, p-value: 1.845e-13 > source("Reg_Diag.R");Reg_Diag(lm.sol) residual s1 standard s2 student s3 hat_matrix s4 DFFITS1 -0.047231639 -0.21248023 -0.20868284 0.13012303 -0.080711402 -0.098070223 -0.42151698 -0.41500522 0.04704358 -0.092207713 0.074

15、288624 0.33492116 0.32934525 0.13385955 0.129473814 -0.006645926 -0.03003380 -0.02947287 0.13797634 -0.011791395 0.581059204 * 2.55701395 * 2.88236603 * 0.09091719 0.911528866 -0.107785364 -0.46031439 -0.45349258 0.03475104 -0.086046747 0.300758350 1.31532456 1.33418993 0.07955382 0.392237398 0.4248

16、10360 2.05723960 * 2.19842345 * 0.24932956 * 1.266991129 -0.027532493 -0.12804079 -0.12568545 0.18600211 -0.0600803310 -0.026629932 -0.11546376 -0.11333335 0.06356511 -0.0295276111 -0.497785364 -2.12587089 * -2.28622467 * 0.03475104 -0.4337935912 0.061913782 0.26540305 0.26078220 0.04194215 0.054564

17、1513 0.112816344 0.48968055 0.48267493 0.06556908 0.1278588114 -0.150249714 -0.65395500 -0.64687388 0.07069034 -0.1784101015 0.104927089 0.45112292 0.44436784 0.04761107 0.0993549316 0.154341375 0.66319490 0.65616401 0.04652075 0.1449372917 0.057639541 0.25360011 0.24915642 0.09056633 0.0786266818 -

18、0.146012230 -0.64156026 -0.63442169 0.08813106 -0.1972315219 -0.124487198 -0.53776150 -0.53055795 0.05659354 -0.1299471720 -0.040713930 -0.18584177 -0.18248454 0.15505538 -0.0781727521 -0.199843357 -0.88485598 -0.88118586 0.10202733 -0.2970258322 -0.359558498 -1.59386063 -1.64328265 0.10408399 -0.56

19、01064823 -0.387785364 -1.65609855 -1.71455446 0.03475104 -0.3253235524 -0.010697936 -0.04979066 -0.04886215 0.18729463 -0.0234568025 -0.283315771 -1.25181018 -1.26568782 0.09823492 -0.4177465226 0.017855655 0.08230563 0.08077720 0.17144488 0.0367443327 0.279286070 1.27482211 1.29043074 0.15505538 0.

20、5527948628 0.022483501 0.09864705 0.09682047 0.08548985 0.0296026229 0.174895100 0.76513625 0.75910825 0.08017207 0.2241103830 0.147269942 0.66281470 0.65578162 0.13089383 0.25449685 s5 cooks_distance s6 COVRATIO s71 2.251190e-03 1.2809524 2 2.923723e-03 1.1521157 3 5.778631e-03 1.2769056 4 4.812656

21、e-05 1.2989982 5 * 2.179654e-01 0.5361673 *6 2.542824e-03 1.1330964 7 4.984335e-02 0.9974548 8 * 4.685683e-01 * 0.8945237 9 1.248734e-03 1.3732722 10 3.016556e-04 1.1941261 11 5.423517e-02 0.6696819 12 1.027897e-03 1.1597812 13 5.608624e-03 1.1668135 14 1.084362e-02 1.1487064 15 3.391268e-03 1.14947

22、43 16 7.153137e-03 1.1180504 17 2.134879e-03 1.2226245 18 1.326021e-02 1.1728006 19 5.782640e-03 1.1493238 20 2.112633e-03 1.3203083 21 2.965359e-02 1.1417402 22 9.837757e-02 0.9293112 23 3.291392e-02 0.8413370 24 1.904437e-04 1.3775853 25 5.690208e-02 1.0379534 26 4.672410e-04 1.3505881 27 9.941147

23、e-02 1.1001732 28 3.032306e-04 1.2232439 29 1.700877e-02 1.1399973 30 2.205512e-02 1.2266609 > toothpaste<-data.frame(+ X1=c(-0.05, 0.25,0.60,0,0.20, 0.15,-0.15, 0.15,+ 0.10,0.40,0.45,0.35,0.30, 0.50,0.50, 0.40,-0.05,+ -0.05,-0.10,0.20,0.10,0.50,0.60,-0.05,0, 0.05, 0.55),+ X2=c( 5.50,6.75,7.25

24、,5.50,6.50,6.75,5.25,6.00,+ 6.25,7.00,6.90,6.80,6.80,7.10,7.00,6.80,6.50,+ 6.25,6.00,6.50,7.00,6.80,6.80,6.50,5.75,5.80,6.80),+ Y =c( 7.38,8.51,9.52,7.50,8.28,8.75,7.10,8.00,+ 8.15,9.10,8.86,8.90,8.87,9.26,9.00,8.75,7.95,+ 7.65,7.27,8.00,8.50,8.75,9.21,8.27,7.67,7.93,9.26)+ )> > lm.sol<-lm(

25、YX1+X2,data=toothpaste)> summary(lm.sol)Call:lm(formula = Y X1 + X2, data = toothpaste)Residuals: Min 1Q Median 3Q Max -0.37130 -0.10114 0.03066 0.10016 0.30162 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.0759 0.6267 6.504 1.00e-06 *X1 1.5276 0.2354 6.489 1.04e-06 *X2 0.6138 0.1027 5.974 3.63e-06 *

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論