版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、實(shí)驗(yàn)八多元線性回歸與逐步回歸(2學(xué)時(shí))一、實(shí)驗(yàn)?zāi)康暮鸵?.掌握逐步回歸的思想與方法,掌握Matlab中stepwise命令的使用方法.二、實(shí)驗(yàn)內(nèi)容1 .主要語句:逐步回歸命令stepwise提供了交互式畫面,可自由選擇變量,進(jìn)行統(tǒng)計(jì)分析,格式stepwise(X,Y,in,penter,premove)X是自變量數(shù)據(jù),Y是因變量數(shù)據(jù),分別為矩陣,in是矩陣X列數(shù)指標(biāo),給出初始模型中包括的子集,缺省時(shí)設(shè)定為全部自變量不在模型中,penter為變量進(jìn)入時(shí)顯著性水平,缺省時(shí)=0.05,premove為變量剔除時(shí)顯著性水平,缺省=0.10.在應(yīng)用stepwise命令進(jìn)行運(yùn)算時(shí),程序不斷提醒將某個(gè)變量
2、加入(Movein)回歸方程,或提醒將某變量從回歸方程中剔除(Moveout).注意:應(yīng)用stepwise命令,數(shù)據(jù)矩陣X第一列不需人工加一個(gè)全1向量,程序會(huì)自動(dòng)求出回歸方程常數(shù)項(xiàng)(intercept).2 .實(shí)驗(yàn)數(shù)據(jù)與內(nèi)容選取1989-2003年的全國統(tǒng)計(jì)數(shù)據(jù),考慮的自變量包括:x1-工業(yè)總產(chǎn)值(億元);x2-農(nóng)業(yè)總產(chǎn)值(億元);x3-建筑業(yè)總產(chǎn)值(億元);x4-社會(huì)商品零售總額(億元);x5-全民人口數(shù)(萬人);x6-受災(zāi)面積;y-國家財(cái)政收入(億元)。數(shù)據(jù)見表3-20,(1)建立多元回歸模型Y=Po+PiXi+P2X2+P3X3+P4X4+P5X5+P6X6+&,求回歸參數(shù)的估計(jì)
3、;(2)對(duì)上述回歸模型和回歸系數(shù)進(jìn)行檢驗(yàn)(要寫出統(tǒng)計(jì)量);(3)用逐步回歸求y與6個(gè)因素之間的回歸關(guān)系式.表3-201989-2003年統(tǒng)計(jì)數(shù)據(jù)年份X1X2X3X4X5X6y19896484.004100.60794.008101.40112704.046991.002664.9019906858.004954.30859.408300.10114333.038474.002937.1019918087.105146.401015.109415.60115823.055472.003149.48199210284.505588.001415.0010993.70117171.051333.00
4、3483.37199314143.806605.102284.7012462.10118517.048829.004348.95199419359.609169.203012.6016264.70119850.055043.005218.10199524718.3011884.603819.6020620.00121121.045821.006242.20199629082.6013539.804530.5024774.10122389.046989.007407.99199732412.1013852.504810.6027298.90123626.053429.008651.1419983
5、3387.9014241.905231.4029152.50124761.050145.009875.95199935087.2014106.205470.6031134.70125786.049981.0011444.08200039047.3013873.605888.0034152.60126743.054688.0013395.23200142374.6014462.806375.4037595.20127627.052215.0016386.04200245975.2014931.507005.0042027.10128453.047119.0018903.64200353092.9
6、014870.108181.3045842.00129227.054506.0021715.25解:(1)建立多元回歸模型建立多元線性回歸模型Y=:0.:lXi2X2-3X3.:4乂.;1)程序:data=19896484.004100.60794.008101.40112704.046991.002664.9019906858.004954.30859.408300.10114333.038474.002937.1019918087.105146.401015.109415.60115823.055472.003149.48199210284.505588.001415.0010993.70
7、117171.051333.003483.37199314143.806605.102284.7012462.10118517.048829.004348.95199419359.609169.203012.6016264.70119850.055043.005218.10199524718.3011884.603819.6020620.00121121.045821.006242.20199629082.6013539.804530.5024774.10122389.046989.007407.99199732412.1013852.504810.6027298.90123626.05342
8、9.0086519014241.905231.4029152.50124761.050145.009875.95199935087.2014106.205470.6031134.70125786.049981.0011444.08200039047.3013873.605888.0034152.60126743.054688.0013395.23200142374.6014462.806375.4037595.20127627.052215.0016386.04200245975.2014931.507005.0042027.10128453.047119.00189
9、03.64200353092.9014870.108181.3045842.00129227.054506.0021715.25;n,p=size(data);%讀取彳T數(shù)n為樣本數(shù),列數(shù)p為回歸參數(shù)個(gè)數(shù)x=ones(n,1),data(:,2:7);%建立設(shè)計(jì)矩陣,第一列全是1y=data(:,8);%讀取Yb,bint,r,rint,stats=regress(y,x);%建立線性回歸模型,輸出回歸參數(shù)b,回歸參數(shù)b的置信區(qū)間,殘差r,殘差r的置信區(qū)間,輸出幾個(gè)統(tǒng)計(jì)量stats結(jié)果輸出:b,bint,r,rint,stats結(jié)果:回歸參數(shù)估計(jì)值b=1.0e+03*-6.92260.0001
10、-0.00090.00000.00060.0001-0.0000得?=(-6.9226,0.0001,-0.0009,0.0000,0.0006,0.0001,-0.0000)T回歸參數(shù)置信區(qū)問:bint=1.0e+04*-4.16302.7785-0.00010.0001-0.0001-0.0001-0.00030.00030.00000.0001-0.00000.0000-0.00000.0000得回歸參數(shù)B的置信區(qū)間如上輸出殘差值r=-228.1801132.3052382.5207-382.0969-164.3261413.2697235.0416-64.6531-215.4275-8
11、3.5491-101.2389-476.3158462.614592.4558-2.4199得到殘差向量?=(-228.1801,132.3052,382.5207,-382.0969,-164.3261,413.2697,235.0416,-64.6531,-215.4275,-83.5491,-101.2389,-476.3158,462.6145,92.4558,-2.4199T輸出隨機(jī)誤差項(xiàng)£=(&述2,,5)T的置信區(qū)問rint=1.0e+03*-0.70470.2484-0.38350.6481-0.17040.9354-1.06510.3009-0.71590.
12、3872-0.25251.0791-0.48820.9583-0.80890.6795-0.79990.3690-0.81920.6521-0.85530.6528-1.15400.2014-0.20461.1299-0.55190.7368-0.40230.3974輸出統(tǒng)計(jì)量結(jié)果:stats=1.0e+05*0.00000.00620.00001.4152R2=0.99785接近1,相關(guān)性強(qiáng),=SSR/p=62056071.F0056,15-6-1,SSE/(n-p-1)p=PF(p,p-1)F。=3.1585*10-5<0.05,均說明自變量對(duì)y線性關(guān)系顯著。;?2n14152401
13、212注意:stats轉(zhuǎn)成長格式數(shù)據(jù)命令和結(jié)果:formatlonggstats結(jié)果:99785.601208397862056071.9039513.15856319868346e-0514152401212.9742繪制殘差圖命令:ResidualCaseOrderPlot68101214CaseNumber殘差示意圖rcoplot(r,rint)1000800600400sausR2000-200-400-600-800-1000殘差示意圖看出無異常點(diǎn)(2)對(duì)上述回歸模型和回歸系數(shù)進(jìn)行顯著性檢驗(yàn)%求可決系數(shù),進(jìn)彳T相關(guān)性檢驗(yàn),y是因變量Y數(shù)據(jù)TSS=y'*(eye(n)-1/n*
14、ones(n,n)*y;%總離差平方和H=x*inv(x*x)*x'%帽子矩陣ESS=y'*(eye(n)-H)*y;%計(jì)算殘差平方和RSS=y'*(H-1/n*ones(n,n)*y;%計(jì)算回歸平方和MSE=RSS/n-p-1;%計(jì)算均方殘差R2=RSS/TSS;%計(jì)算樣本決定系數(shù)RSS/TSS,相關(guān)性檢驗(yàn)%F僉驗(yàn)檢驗(yàn)回歸方程的顯著性F0=(RSS/p)/(ESS/(n-p-1);%計(jì)算F0Fa=finv(0.95,p,n-p-1);%F分布時(shí)的臨界值%t檢驗(yàn)檢驗(yàn)回歸系數(shù)的顯著性S=MSE*inv(x'*x);%計(jì)算回歸參數(shù)的協(xié)方差矩陣T0=b./sqrt(d
15、iag(S);%每個(gè)回歸參數(shù)的T統(tǒng)計(jì)量,b為上述回歸參數(shù)返回結(jié)果Ta=tinv(0.975,n-p-1);%t分布的上1-0.05/2分位數(shù)pp=2-2*tcdf(abs(T0),n-p-1);%每個(gè)回歸參數(shù)檢驗(yàn)的T統(tǒng)計(jì)量對(duì)應(yīng)的概率pp結(jié)果:TSS=5.2808e+08H=Columns1through60.69000.18140.25720.0049-0.12320.02950.18140.6753-0.08380.14150.1402-0.16300.2572-0.08380.51530.2866-0.04370.14920.00490.14150.28660.32870.19570.09
16、46-0.12320.1402-0.04370.19570.62250.26070.0295-0.16300.14920.09460.26070.3338-0.02670.2168-0.1760-0.05130.13700.09370.13070.0307-0.0756-0.1369-0.04020.0776-0.00360.00810.0637-0.0101-0.20790.09260.0338-0.13530.0506-0.04090.00550.0927-0.0757-0.07670.05210.04420.06690.0422-0.1563-0.03440.09510.1268-0.0
17、0190.0568-0.13310.06940.04310.1084-0.0573-0.05620.01270.1461-0.02020.0376-0.0762-0.21050.1783-0.1163-0.1138Columns7through12-0.13000.12170.1064-0.02670.1307-0.00360.0338-0.0757-0.15630.21680.03070.0081-0.1353-0.0767-0.0344-0.1760-0.07560.06370.05060.05210.0951-0.0513-0.1369-0.0101-0.04090.04420.1268
18、0.1370-0.0402-0.20790.00550.0669-0.00190.09370.07760.09260.09270.04220.05680.34300.23330.22340.05980.01060.02590.23330.35240.13910.26550.1600-0.05700.22340.13910.5619-0.0361-0.10060.23280.05980.2655-0.03610.36460.3135-0.02370.01060.1600-0.10060.31350.32980.03180.0259-0.05700.2328-0.02370.03180.26570
19、.0122-0.06150.1857-0.02990.04870.2537-0.08540.0132-0.14400.14250.23350.0884-0.0165-0.0315-0.0051Columns13through15-0.13310.01270.17830.06940.1461-0.11630.0431-0.0202-0.11380.10840.0376-0.1300-0.0573-0.07620.1217-0.0562-0.21050.10640.0122-0.0854-0.0165-0.06150.0132-0.03150.1857-0.1440-0.0051-0.02990.
20、1425-0.06270.04870.2335-0.08040.25370.08840.0962-0.0627-0.08040.09620.29330.21810.10520.21810.50980.13430.10520.13430.8141R2=0.997856015345558接近1,相關(guān)性顯著.回歸方程顯著性F檢驗(yàn)結(jié)果:F0=349.065936623445Fa=4.14680416227653表明F0=349.0659>F0.05(P,n-p-1)=4.1680模型顯著回歸參數(shù)檢驗(yàn)結(jié)果:回歸參數(shù)檢驗(yàn)t統(tǒng)計(jì)量值T0=-0.02919355319091510.02818787985
21、54941-0.5449042806666820.002027564977241090.2410645568925540.0411337557415811-0.0973456131842114T統(tǒng)計(jì)量上0.05分位數(shù)Ta=2.44691185114497T統(tǒng)計(jì)量檢驗(yàn)P值Pp=0.97770.97840.60550.99840.81750.96850.9256檢驗(yàn)P值P0k,表明每個(gè)變量對(duì)Y回歸均不顯著,需要進(jìn)行模型改進(jìn)。(3)逐步回歸逐步回歸方法1:初始模型選擇全部自變量xx=data(:,2:7);%輸入原始自變量數(shù)據(jù),為x1-x7,第一列不需要1y=data(:,8);%輸入因變量Y數(shù)據(jù)s
22、tepwise(xx,y,1,2,3,4,5,6,0.05,0.1)%初始模型當(dāng)前集為全部自變量集第一步:先將所有變量放入模型中,第一步結(jié)果將x3移除;x5移除;E1寫屈中。聃叼府爾on-n3S44RliEiMm-SwpwiieiUDiWftWitprficiertssrthE>wBa打TL白訕ifej-137?4ifl觀T耳-I2WHrad;-1«277叩BE-3M有。.鰭HW1英由1Q|!»11IM】I皆3st20M1¥Cm"trUtp-nl矍77?WJ4W«Qlf打IQUMACa4N6b-tall口XE&ilE&呻第
23、三步:x6移除;“dHHislory物|J1第3«-i+J4jIJl輸出結(jié)果:HStefmiM!口egfEMionsw百m工me時(shí)一,unpj叩陽»&hiQxiowtiwihEnrrEm.Cm樽LrELn"”l沒有移除和引入的,最優(yōu)自變量集為X2,X4最優(yōu)回歸方程為?=519.678-0.812016x20.72372x4H0為真F(1,12)檢驗(yàn)假設(shè):Ho:-2=N=0選取統(tǒng)計(jì)量F=一邳華一SSE/(15-2-1)R2=0.996923,修正的復(fù)相關(guān)系數(shù)平方(擬合優(yōu)度判別公式)R;=0.99641均接近1,自變量與因變量y線性關(guān)系顯著,F(xiàn)統(tǒng)計(jì)量觀測值Fo=194
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(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ǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 文書模板-《衣帽回收委托協(xié)議書》
- 2024年土地征用委托代理協(xié)議范例
- 2024年高效清洗設(shè)備銷售協(xié)議
- 2024工程協(xié)議管理實(shí)務(wù)精要
- 北京2024二手轎車買賣正式協(xié)議
- 2024年三方租賃場地協(xié)議范例
- DB11∕T 1655-2019 危險(xiǎn)化學(xué)品企業(yè)裝置設(shè)施拆除安全管理規(guī)范
- 2024年BF場地出租協(xié)議模板
- 2024年跨國貿(mào)易代表協(xié)議基本格式
- 2024年分公司加盟協(xié)議模板
- GB/T 2885.6-2008礦用窄軌車輛第6部分:材料車
- GB/T 1393-1987舷梯翻梯裝置
- 橈骨遠(yuǎn)端骨折中醫(yī)治療培訓(xùn)課件
- 例說議題式課堂教學(xué)的模式課件
- 25噸吊車參數(shù)表75734
- 外研版五年級(jí)上冊(cè)說課標(biāo)說教材課件
- 八年級(jí)體育與健康學(xué)科:第二章 素質(zhì)與鍛煉之柔韌練習(xí)教案-柔韌性練習(xí)1
- 遼寧省阜新市基層診所醫(yī)療機(jī)構(gòu)衛(wèi)生院社區(qū)衛(wèi)生服務(wù)中心村衛(wèi)生室名單目錄信息
- 廣播操比賽打分表
- (完整)五金材料采購清單
- 2021年徐州市國盛控股集團(tuán)有限公司校園招聘筆試試題及答案解析
評(píng)論
0/150
提交評(píng)論